c

Purify's Uninit Memory Read (UMR) on class/structure padding

I experience quite annoying side-effect of class/structure padding with Purify. E.g. struct something { int field1; char field2; }; /* ... */ struct something smth, smth2; smth.field1 = 1; smth.field2 = 'A'; smth2 = smth; The last line would highly likely trigger UMR warning saying that 3 bytes of initialized memory are acc...

How to 'web enable' a legacy C++ application

I am working on a system that splits users by organization. Each user belongs to an organization. Each organization stores its data in its own database which resides on a database server machine. A db server may manage databases for 1 or more organizations. The existing (legacy) system assumes there is only one organization, however I ...

uint64_t to int

I'm writing a java binding for a C code and I'm not really familiar with C. I have a uint64_t and need to cast it to a int. Does anyone know how to do that? (My binding returns then a jint...) ...

Compiling x64 dll from x86 using Visual Studio 2008

Hello gurus, I am compiling some external C++ code into a dll using Visual Studio 2008. The code is wrapped in extern "C". Since I am cross compiling, creating a 64 bit dll on my 32 bit machine; I am using x64 as "Active solution platform" in the "Configuration Manager". My dll compiles and links successfully. However when I open it ...

How to make tabs work with win32? I'm not using a dialog

I've created my controls in my window in the WM_CREATE message like this: case WM_CREATE: { CreateWindowA("button", "Refresh Listview", BS_MULTILINE | WS_CHILD | WS_VISIBLE, 10, 10, 70, 50, hwnd, (HMENU)IDC_REFRESHLW, g_hInst, NULL); break; } When I press tab it does nothing, do i have to in...

Problem to compile a C-program by GCC with GD2 library installed via MacPorts

I have successfully compiled a C-program by GCC on Mac with GD2 library installed directly from sources. Now I am trying to do that with GD2 library installed via MacPorts and have the following error message: plotgeometry.c:5:16: error: gd.h: No such file or directory plotgeometry.c: In function 'PlotGeometry': plotgeometry.c:28: erro...

Basic C pointer question

Hi all, It has been a while since I last programmed C, seems I have forgotten everything in the meantime... I have a very simple pointer question. Assuming that I have a function that computes a sum through loop iteration. Not only should this function return the loop counter but also the sum it computed. Since I can just return one val...

Have a LaunchAgent sleep when the computer sleeps.

I'm creating a daemon that will be installed in the LaunchAgents folder. Some questions about making it sleep: Because it's a LaunchAgent item will the executable automatically sleep when the user/system sleeps? If the answer is yes to question 1, do I need to specify anything in the plist document? If the answer is no to question 1, w...

Best online source for learning C

Hi Im an experienced actionscript developer, and relatively new to Objective C. I decided a good investment of my time would be to master the C language (not C# or C++). Can anyone recommend the 'best' online tutorials for learning C? ...

DOS ASCII Animation Lagging without constant input, Turbo C compiled

Here's an oddity from the past! I'm writing an ASCII Pong game for the command prompt (Yes yes oldschool) and I'm writing to the video memory directly (Add. 0xB8000000) so I know I'm rendering quickly (As opposed to gotoxy and then printf rendering) My code works fine, the code compiles fine under Turbo C++ V1.01 BUT the animation lags...

What does the C compiler do with bitfields?

I'm working on an embedded project (PowerPC target, Freescale Metrowerks Codewarrior compiler) where the registers are memory-mapped and defined in nice bitfields to make twiddling the individual bit flags easy. At the moment, we are using this feature to clear interrupt flags and control data transfer. Although I haven't noticed any bu...

What is the simplest way you can imagine to formulate a simplistic audio equalizer for a computer game?

The idea is that a game might need something fast but also simplistic. Mainly a "give me more highs or give me more lows" kind of thing. I googled whole libraries of audio processing but that might not be ideal. What do you think is the best way to formulate a very simplistic approach suitable for the quick switching for a computer game?...

Running JVM inside Windows C console app becomes zombie if debugging is stopped in the middle

I wrote a C program that starts a JVM using JNI_CreateJavaVM. The program is a Windows console application (VC 2008). JNI version is 1.6. If I debug the program and then stop the debugging in the middle, before it reaches the call to DestroyJavaVM then the CMD.exe window remains open and I'm unable to close or kill it. If I look at the ...

Cast to int vs floor

Is there any difference between these: float foo1 = (int)(bar / 3.0); float foo2 = floor(bar / 3.0); As I understand both cases have the same result. Is there any difference in the compiled code? Note: updated fabs() to floor() as that was the real question ...

file name matching with wildcard

Hello, I need to implement something like my own file system. One operation would be the FindFirstFile. I need to check, if the caller passed something like ., sample*.cpp or so. My "file system" implementation provides the list of "files names" as a array of char*. Is there any Windows function or any source code that implements this ...

Project Idea in Python or C#

Hi So far I was familiar with c and c++ only, and I have programmed in these languages only. I have some experience working on some projects in c or c++. Some good projects or applications I've made till now: Duplicate file finder and remover Process monitor on Linux Basic http proxy server I have made one small flex application ...

Super high performance C/C++ hash map (table, dictionary)

I need to map primitive keys (int, maybe long) to struct values in a high-performance hash map data structure. My program will have a few hundred of these maps, and each map will generally have at most a few thousand entries. However, the maps will be "refreshing" or "churning" constantly; imagine processing millions of add and delete m...

Using a C/C++ data structure in a C# program

I have a super high-performance C/C++ data structure (see here!) that I'd like to access and use in my C# program. Imagine the C/C++ data structure has a public API (get, add, delete, etc). How can I call these methods lots of times within C# in a high-performance way? P.S. Before you criticize my use of the phrase "C/C++"... In my vie...

c++ win32: how to set back color of a window?

I can set the back color when i am registering the class, e.g.: wincl.hbrBackground = CreateSolidBrush(RGB(202, 238, 255)); RegisterClassEx(&wincl); But how would i do it to any window i have created with the CreateWindow function? like a button on my main window, i have visual styles enabled, and i can notice the windows default gray...

scanf / field lengths : using a variable / macro, C/C++

How can I use a variable to specify the field length when using scanf. For example: char word[20+1]; scanf(file, "%20s", word); Also, is it correct to use 20+1 (since it needs to add a \0 at the end?). Instead, I'd like to have something like: #define MAX_STRING_LENGTH 20 and then char word[MAX_STRING_LENGTH+1]; scanf(file, "%"MAX...