From: Jeffrey C. <jef...@co...> - 2013-02-16 14:18:13
|
There's a simple solution to all this wailing and gnashing of teeth. Compile the code base as if it were C++. There's no need to use any of C++'s advanced features. C is mostly a subset of C++ and most C code will compile as C++ with only minor changes. In my experience, the only item that usually needs attention is the C++ requirement to explicitly cast void * to specific pointer types. That is int *i = malloc(6*sizeof(int)); needs to be changed to int *i = (int *)malloc(6*sizeof(int)); Also note that C++ programs can make full use of legacy C libraries if necessary. - Jeff -----Original Message----- From: dmarkle [mailto:dm...@as...] Sent: Saturday, February 16, 2013 9:05 AM To: For developer discussion of xTrkCad Subject: Re: [Xtrkcad-fork-developers] C99 on Windows On Sat, 16 Feb 2013 14:34:37 +0100, "Martin Fischer" <mar...@t-...> wrote: > I'd hate to loose the excellent IDE that Microsoft has though. The problem being that Microsoft considers C obsolete, isn't making any improvements to it, and as time goes on it has been drifting farther and farther from the current standards. C has continued moving forward, making improvements, and has continued to outstrip C++ in popularity but we're still stuck with ancient MSVC conventions. Take for instance a change I've been looking to make to fix 64 bit compile warnings in gtkhelp.c: xtrkcad/app/wlib/gtklib/gtkhelp.c: In function ‘DoHelpMenu’: xtrkcad/app/wlib/gtklib/gtkhelp.c:705:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] Recommended way to fix this: --- a/app/wlib/gtklib/gtkhelp.c Sat Feb 16 08:43:23 2013 +0100 +++ b/app/wlib/gtklib/gtkhelp.c Sat Feb 16 08:57:35 2013 -0500 @@ -702,7 +702,7 @@ static void DoHelpMenu( void *data ) { - int func = (int)data; + int func = (intptr_t)data; switch( func ) { Microsoft doesn't support intptr_t, which has been part of the new C spec for a decade to improve 64 bit platform support. In this case there's a workaround, but it involves adding more code to every file we need to use this: #ifdef _WIN32 typedef signed short intptr_t #else #include <stdint.h> #endif There's also the point of declarations in blocks which came up in the last few days; that's an improvement to the language that can be used to create more readable code. ------------------------------------------------------------------------------ The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials, tech docs, whitepapers, evaluation guides, and opinion stories. Check out the most recent posts - join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ xTrkCad mailing list <a href="http://sourceforge.net/projects/xtrkcad-fork">http://sourceforge.net/projects/xtrkcad-fork</a> Xtrkcad-fork-developers mailing list Xtr...@li... https://lists.sourceforge.net/lists/listinfo/xtrkcad-fork-developers |