Pelles C forum

Pelles C => Bug reports => Topic started by: PVozenilek on February 11, 2017, 04:55:32 PM

Title: _Pragma
Post by: PVozenilek on February 11, 2017, 04:55:32 PM
Pelles C supports _Pragma from C99. Unfortunately it is buggy.

Code: [Select]
#include <stdio.h>
static int i = 0;
static void __cdecl foo(void) {
  ++i;
}
#pragma startup foo // this works, i gets incremented


// this fails to compile
#define BAR() \
  static void __cdecl bar(void) { ++i; } \
  _Pragma("startup bar") \
  /**/

   
BAR()

int main(void)
{
  printf("i = %d\n", i);
  return 0;
}

Compiler error is:

Code: [Select]
Building a.obj.
O:\a\a.c(17): warning #2099: Missing type specifier; assuming 'int'.
O:\a\a.c(17): error #2001: Syntax error: expected ')' but found 'string constant'.
O:\a\a.c(17): error #2001: Syntax error: expected ';' but found ')'.
O:\a\a.c(17): warning #2135: Static 'bar' is not referenced.
*** Error code: 1 ***
Done.


I had tried all the tricks: adding/removing parenthesis, semicolon, putting the _pragma before/after. Nothing helped.