Search code examples
csolarisportabilityconditional-compilation

Is there a good online tutorial for writing portable C?


I have some tools I'm working on in portable C that works in Windows Visual Studio 2008 and gcc in Ubuntu Linux based on #ifdef _WIN32 but adding support for Solaris seems to be trickier, especially if I want to support cc as well as gcc.

For one example I have some code which sprintfs into an allocated memory buffer which uses vasprintf on Linux/gcc and _vscprintf/vsprintf on Windows/MSVC. Neither are available on Solaris where I could use vsnprintf but I have no idea what to add to my #ifdefs or whether I should move to something else.

Hopefully I don't have to move to configure with cygwin, mingw.


Solution

  • The autoconf(1) manual has a section on portable C programming.