Pelles C forum

Pelles C => Bug reports => Topic started by: JohnF on June 17, 2014, 08:12:42 PM

Title: LIB_EXT errors
Post by: JohnF on June 17, 2014, 08:12:42 PM
If I add __STDC_WANT_LIB_EXT2__ to preprocessor symbols these errors are reported.

..\stdio.h(273): error #1019: Syntax error in #if/#elif expression.
..\string.h(113): error #1019: Syntax error in #if/#elif expression.
..\wchar.h(238): error #1019: Syntax error in #if/#elif expression.

and with __STDC_WANT_LIB_EXT1__ I get these.

..\stdio.h(224): error #1019: Syntax error in #if/#elif expression.
..\stdlib.h(183): error #1019: Syntax error in #if/#elif expression.
..\string.h(79): error #1019: Syntax error in #if/#elif expression.
..\wchar.h(188): error #1019: Syntax error in #if/#elif expression.


John
Title: Re: LIB_EXT errors
Post by: neo313 on June 17, 2014, 10:38:48 PM
Cannot replicate, next time you post a bug it would be helpful to include more details.
Title: Re: LIB_EXT errors
Post by: JohnF on June 18, 2014, 06:54:37 AM
#define __STDC_WANT_LIB_EXT2__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <io.h>

John
Title: Re: LIB_EXT errors
Post by: frankie on June 18, 2014, 10:01:47 AM
Hi John.
Giving a value to __STDC_WANT_LIB_EXT2__ solves the problem.

#define __STDC_WANT_LIB_EXT2__ 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <io.h>


This comes from the test in stdio.h and string.h:

#if __STDC_WANT_LIB_EXT2__

It would have worked should it have been:

#ifdef __STDC_WANT_LIB_EXT2__

I don't know if this could be a bug. I would expect that the preprocessor should resolve to a value=0 for both undefined symbol and for a definition without a value.

P.S. PellesC help anyway states:
QuoteTo enable the extended functions in Pelles C, define the macro __STDC_WANT_LIB_EXT2__ as the integer constant 1.

EDIT: OK I have got it. #if deals only with numbers, and the code:

#if something

Is equivalent by default to:

#if something != 0

The definition of a symbol without a value is an undefined type and triggers the error.
Not a bug. 8)
Title: Re: LIB_EXT errors
Post by: JohnF on June 18, 2014, 11:04:20 AM
Well done Frankie, thanks.

John