Getting ride of all the warnings

I am generally a C# developer, but these days, I own, maintain and write a lot of C code. My two main projects with C are the Mesh Agent and the UPnP Microstack, both share a lot of code and in the case of the UPnP stack, it's quite widely used.

Recently someone mentioned that as part of their product release, they have the requirement of not having any warning even when the compiler is set to the highest warning level (Level 4 on Visual Studio). For a long time, I have set the top warning level on Linux (/Wall) and fixed all the warnings but never bothered to to the same in Windows. Well, now I needed to do it.

This weekend I put the UPnP stack to the highest warning level on Windows and compiled to get 1000's of warning messages! ouch. I then proceeded to spend 15 hours of my long weekend fixing warnings... mostly like a robot in front of the screen since it's very repetitive.

I did learn a few things in the process. First, I have no idea that data pointers and function pointers are different. Compilers don't like that you cast a function pointer to a void*. They could in theory... be different size. There is no equivalent of void* for function pointers, but you can define one yourself.

I also learned more about macro definitions. You can define a macro with an undefined list of arguments. For example:

#define eprintf(...) fprintf (stderr, __VA_ARGS__)

I had no idea. This made some of my macros simpler. One of the major fixes was to use secure versions of methods like sprintf, you have to use snprintf_s on Windows, but you don't want to break compatibility with Linux.

In any case, I have a new version of the Developer Tools for UPnP Technologies with all these fixed included. Should make product engineers happy.


For more complete information about compiler optimizations, see our Optimization Notice.


mimepp's picture

DLNABuilder.exe ?

Beside DeviceBuilder.exe, as I know "Intel® Digital Home Device Code Wizard" has another tool named: "Launch Code Wizard", DLNABuilder.exe
Which will generate different source code includes DLNA profile support.
Intel® Digital Home Device Code Wizard
Version: 1.0.2777 Updated: August 13, 2007

Is this DLNABuilder.exe out-of-date ?

yuanyuan3558's picture

Great article. It is wonderful!