NO

Author Topic: Error including <stdnoreturn.h> and <stdlib.h>  (Read 2746 times)

kst

  • Guest
Error including <stdnoreturn.h> and <stdlib.h>
« on: August 30, 2012, 06:52:25 AM »
Compiler version: Pelles C for Windows, Version 7.00.350 (Win64) under Windows 7 Ultimate 64 bits

When I compile the attached source file "noreturn_bug.c", I get the errors in the attached "noreturn_bug.log".

Reversing the order of the #include directives avoids the problem (and lets me use the "noreturn" macro).

For quick reference, the source file looks like:

#include <stdnoreturn.h>
#include <stdlib.h>
int main(void) {
}


and the error log starts with:

Building noreturn_bug.obj.
C:\Program Files\PellesC\Include\stdlib.h(84): error #2001: Syntax error: expected ')' but found '_Noreturn'.
C:\Program Files\PellesC\Include\stdlib.h(84): warning #2099: Missing type specifier; assuming 'int'.
C:\Program Files\PellesC\Include\stdlib.h(84): error #2014: Empty declaration.
C:\Program Files\PellesC\Include\stdlib.h(84): error #2001: Syntax error: expected ';' but found ')'.


Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Error including <stdnoreturn.h> and <stdlib.h>
« Reply #1 on: September 01, 2012, 09:32:06 PM »
Right. The "noreturn" macro from stdnoreturn.h turns an internal __declspec(noreturn) into __declspec(_Noreturn), which isn't valid. I will fix this.

If you want this fixed now, before I can upload a new version, you can do the following:

Open the file crtdef.h in any text editor and change the line (~ line 9) from:

Code: [Select]
#define _CRTEND  __declspec(noreturn)
to:

Code: [Select]
#if __POCC_STDC_VERSION__ >= 201101L
#define _CRTEND  _Noreturn
#else /* __POCC_STDC_VERSION__ < 201101L */
#define _CRTEND  __declspec(noreturn)
#endif /* __POCC_STDC_VERSION__ < 201101L */

This should solve the problem...
/Pelle