Thread: Barely C based question, how to define a wprintf style function attribute in GNUC

  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,737

    Barely C based question, how to define a wprintf style function attribute in GNUC

    So I got this:
    Code:
    #ifdef __GNUC__
    #define PAW__ATTR_PRINTF(ARGS_POS,VA_POS) \
    	__attribute__((format (printf, ARGS_POS, VA_POS)))
    #define PAW__ATTR_WPRINTF(ARGS_POS,VA_POS) \
    	__attribute__((format (wprintf, ARGS_POS, VA_POS)))
    #else
    #define PAW__ATTR_PRINTF(ARGS_POS,VA_POS)
    #define PAW__ATTR_WPRINTF(ARGS_POS,VA_POS)
    #endif
    
    #ifdef _DEBUG
    #define PAW_ATTR_PRINTF(ARGS_POS,VA_POS) PAW__ATTR_PRINTF(ARGS_POS,VA_POS)
    #define PAW_ATTR_WPRINTF(ARGS_POS,VA_POS) PAW__ATTR_WPRINTF(ARGS_POS,VA_POS)
    #else
    #define PAW_ATTR_PRINTF(ARGS_POS,VA_POS)
    #define PAW_ATTR_WPRINTF(ARGS_POS,VA_POS)
    #endif
    I tried just printf but gcc did not like that because the arguments were of wchar_t const * like wprintf so I tried wprintf and gcc still didn't like it because there's no such attribute, is there any way to get gcc to check the arguments match what is expected in those functions?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trying to code a C-style function as a C++ one
    By thames in forum C++ Programming
    Replies: 4
    Last Post: 12-16-2012, 08:55 AM
  2. warning on wprintf
    By std10093 in forum C Programming
    Replies: 5
    Last Post: 10-09-2012, 03:53 AM
  3. Bug in my barely-started text-based game program
    By linkofazeroth in forum C++ Programming
    Replies: 18
    Last Post: 08-30-2005, 01:32 AM
  4. reinterpret_cast, C-style cast or function-style cast
    By blight2c in forum C++ Programming
    Replies: 3
    Last Post: 05-14-2002, 10:07 PM

Tags for this Thread