Skip to content

Instantly share code, notes, and snippets.

@chenzx
Last active December 14, 2015 15:09
Show Gist options
  • Save chenzx/5105971 to your computer and use it in GitHub Desktop.
Save chenzx/5105971 to your computer and use it in GitHub Desktop.
Useful C/C++ macros
#ifdef _DEBUG
#ifdef _WIN32
#define dprintf(format,...) fprintf(stdout, "%s:%d:%s " format , __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
#else
//gcc:
#define dprintf(format, args...) fprintf(stdout, "%s:%d:%s " format, __FILE__, __LINE__, __FUNCTION__, ## args)
#endif
#else
#define dprintf(format, args...)
#endif
#if defined(BUILD_DLL)
#if defined WIN32
#define XYZ_API __declspec(dllexport)
#else //GCC
#define XYZ_API __attribute__ ((visibility ("default")))
#endif
#else
#if defined _WIN32
#define XYZ_API __declspec(dllimport)
#else //GCC
#define XYZ_API
#endif
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment