c

What is the best free memory leak detector for a C/C++ program and its plug-in DLLs?

I have a .exe and many plug-in .dll modules that the .exe loads. (I have source for both.) A cross-platform (with source) solution would be ideal, but the platform can be narrowed to WinXP and Visual Studio (7.1/2003 in my case). The built-in VS leak detector only gives the line where new/malloc was called from, but I have a wrapper for...

Overloaded functions in C++ DLL def file

I'm writing a C/C++ DLL and want to export certain functions which I've done before using a .def file like this LIBRARY "MyLib" EXPORTS Foo Bar with the code defined as this, for example: int Foo(int a); void Bar(int foo); However, what if I want to declare an overloaded method of Foo() like: int Foo(int a, int b); As the de...

What is the best way to organize my C project code and its external libraries?

I'm starting a new C project, which is largely OSS-based. It'll also be on SourceForge, and I'd like to take this opportunity to learn established best practices for organizing this kind of code. I'm using libraries like libcurl and libz, and I'll compile it using MinGW and MSYS. I'll be distributing copies the source of all libraries I...

The Google Calculator Glitch, could float vs. double be a possible reason?

I did this Just for kicks (so, not exactly a question, i can see the downmodding happening already) but, in lieu of Google's newfound inability to do math correctly (check it! according to google 500,000,000,000,002 - 500,000,000,000,001 = 0), i figured i'd try the following in C to run a little theory. int main() { char* a = "399999...

C: Network Programming

I am relatively new to the C language, but I'm a very fast learner. I'm looking to do some basic network programming in C but I'm not sure how to start. Could anyone point me to a good guide or tutorial for C Network Programming? ...

Whats the fastest way to multiply a 16-bit integer by a double?

I want to to do this, on an 8-bit micro controller 16bit_integer = another_16bit_integer * 0.997; with the least possible number of instructions. ...

MFC resources / links

I am about to reenter the MFC world after years away for a new job. What resources to people recommend for refreshing the memory? I have been doing mainly C# recently. Also any MFC centric websites or blogs that people recommend? ...

c/c++ source code visualization?

Basically I want tools which generate function call graph, dependency graph etc. ...

Is GCC broken when taking the address of an argument on ARM7TDMI?

My C code snippet takes the address of an argument and stores it in a volatile memory location (preprocessed code): void foo(unsigned int x) { *(volatile unsigned int*)(0x4000000 + 0xd4) = (unsigned int)(&x); } int main() { foo(1); while(1); } I used an SVN version of GCC for compiling this code. At the end of function fo...

Most Pythonic way equivalent for: while ((x = next()) != END)

What's the best Python idiom for this C construct? while ((x = next()) != END) { .... } I don't have the ability to recode next(). update: and the answer from seems to be: for x in iter(next, END): .... ...

C on Visual Studio

I'm trying to learn C. As a C# developer, my IDE is Visual Studio. I've heard this is a good environment for C/C++ development. However, it seems no matter what little thing I try to do, intuition fails me. Can someone give good resources for how to either: learn the ins and out of C in Visual Studio recommend a better C IDE + compiler...

Whats the best way to shift an array of bytes by 12-bits?

With gcc, I want to shift the contents of an array of bytes by 12-bit to the left. For example, starting with this array: uint8_t shift[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0x0A, 0xBC}; I'd like to shift it to the left by 12-bits resulting in: 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAB, 0xC0, 0x00 ...

Get current process CPU usage in C

On Windows I can do: HANDLE hProcess = GetCurrentProcess(); FILETIME ftCreation, ftExit, ftKernel, ftUser; GetProcessTimes(hProcess, &ftCreation, &ftExit, &ftKernel, &ftUser); SYSTEMTIME stKernel; FileTimeToSystemTime(&ftKernel, &stKernel); SYSTEMTIME stUser; FileTimeToSystemTime(&ftUser, &stUser); printf("Time in kernel mode = %uh...

Change own process priority in C

On Windows I can do: HANDLE hCurrentProcess = GetCurrentProcess(); SetPriorityClass(hCurrentProcess, ABOVE_NORMAL_PRIORITY_CLASS); How can I do the same thing on *nix? ...

How do you get the filename of a tempfile to use in Linux?

Let's say I'm creating a program in C that needs to use a tempfile. Creating an ad hoc tempfile in /tmp is probably not a good idea. Is there a function or OS call to supply me with a tempfile name so that I can begin to write and read from it? ...

Is there a wxWidgets framework for C?

My understanding is that wxWidgets is for a number of programming languages (C++, Python, Perl, and C#/.NET) but that does not include C. Is there a similar framework for the C programming language, or is this not something that C is used for? ...

What is your favourite non-standard C library function ?

It has to be in a 'system' C library, not an add-on library, but it can be from any C version/compiler/system/... Mine's strfry, from glibc, the GNU C library: The strfry() function randomizes the contents of string by using rand(3) to randomly swap characters in the string. The result is an anagram of string. ...

What is a good open source B-tree implementation in C?

I am looking for a lean and well constructed open source implementation of a B-tree library written in C. It needs to be under a non-GPL license so that it can be used in a commercial application. Ideally, this library supports the B-tree index to be stored/manipulated as a disk file so that large trees can be built using a configurable ...

Which 4.x version of gcc should one use?

The product-group I work for is currently using gcc 3.4.6 (we know it is ancient) for a large low-level c-code base, and want to upgrade to a later version. We have seen performance benefits testing different versions of gcc 4.x on all hardware platforms we tested it on. We are however very scared of c-compiler bugs (for a good reason hi...

Automatic image rotation based on a logo

We're looking for a package to help identify and automatically rotate faxed TIFF images based on a watermark or logo. We use libtiff for rotation currently, but don't know of any other libraries or packages I can use for detecting this logo and determining how to rotate the images. I have done some basic work with OpenCV but I'm not...