NO

Author Topic: _Pragma() not handle concatination of string literals  (Read 74 times)

Offline Prokrust

  • Member
  • *
  • Posts: 3
_Pragma() not handle concatination of string literals
« on: January 18, 2021, 11:19:56 am »
Not compile
_Pragma("startup " "func1");

error #1052: Syntax error in '_Pragma' operator.
error #2001: Syntax error: expected ')' but found 'string constant'.

Offline Prokrust

  • Member
  • *
  • Posts: 3
Re: _Pragma() not handle concatination of string literals
« Reply #1 on: January 20, 2021, 03:14:04 pm »
//This is a complete example of a compilation error
//macros ZINITIALIZE(init) compile _Pragma("startup" "init")

#include <stdio.h>
#include <stdlib.h>

#ifdef __POCC__
#define WIN32_DEFAULT_LIBS
#define __STDC_WANT_LIB_EXT1__  1
#define ZINITIALIZE(NameInit)  _ZINITIALIZE1(NameInit)
#define _ZINITIALIZE1(NameInit)  _ZINITIALIZE2(NameInit)
#define _ZINITIALIZE2(NameInit)  _Pragma("startup " #NameInit)

#elif defined(__MINGW64__)
#define ZINITIALIZE(NameInit)  void __cdecl NameInit(void) __attribute__((constructor))
#endif
void init(void);

int main(int argc, char *argv[]) {
   return 0;
}

ZINITIALIZE(init);
//_Pragma("startup" "init");
void init(void) {
   printf("Init!\n");
}