Pelles C forum

Pelles C => Bug reports => Topic started by: Converter on February 04, 2008, 05:52:11 PM

Title: Problem with ANSI 99 bool in windows includes
Post by: Converter on February 04, 2008, 05:52:11 PM
Hi,

I searched the forum and couldn't find this discussed. I recompile working code from another compiler but when I compile one file (Win32) I get this:

Building Dbg.obj.
C:\Program Files\PellesC\Include\Win\oaidl.h(261): fel #2067: Otillåten användning av '_Bool'.
C:\Program Files\PellesC\Include\Win\oaidl.h(261): fel #2047: Förväntade ett fältnamn.
C:\Program Files\PellesC\Include\Win\propidl.h(206): fel #2067: Otillåten användning av '_Bool'.
C:\Program Files\PellesC\Include\Win\propidl.h(206): fel #2047: Förväntade ett fältnamn.

(I get Swedish error messages even if I have an English XP and English IDE but for someone else looking the first means "Illegal use of" and the second "expected a field name").

the actual line is in a union:

           union {
...
                VARIANT_BOOL boolVal;
                _VARIANT_BOOL bool;
...

so it seems that my inclusion of the ANSI 99 <stdbool.h> /* stdbool.h - C99 standard header */ (that typedefs bool) breaks it.

I guess I can find a way not to include these two h-files but it may break other dependencies, the other compiler has the same use of bool as name in the same h-files but there they never get included there. Perhaps there is a defined constant that can be undefined to exclude this inclusion? I could avoid using bool and isntead use the windows-defined BOOL but I have many libraries that are generic and not only use with Windows so a standard bool is better.

I just started looking into Pelles C and I really like it so far.

Best
Title: Re: Problem with ANSI 99 bool in windows includes
Post by: Converter on February 06, 2008, 02:36:53 PM
Some more info:

I first thought this was a bug since (from memory) I thought bool was a typedef and then the struct member bool in the included file would be in another namespace and should be OK, but I now see that <stdbool.h> bool is a macro so it is nothing wrong just one of these things that easily can happen in C especially when mixing code using old C standards (like the Win API) with C99.

That the compiler error messages are in Swedish in spite of an English IDE and XP (and I never checked Swedish language installation) seems like a bug though but I can live with that (since I am Swedish, I just don't like to mix languages, while programming I am in "English mode").

After a lot of test compilation of I still realy like what I see but I haven't yet reached the point were I can compare speed (which was one reasons for testing Pelles C).
Title: Re: Problem with ANSI 99 bool in windows includes
Post by: TimoVJL on February 06, 2008, 06:34:06 PM
What this program shows to you ?

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

int __cdecl WinMainCRTStartup(void)
{
TCHAR szTmp[512];

LCID lcidt = GetThreadLocale();
LCID lcids = GetSystemDefaultLCID();
LCID lcidu = GetUserDefaultLCID();
wsprintf(szTmp, "ThreadLocale  %04Xh\n"
"SystemDefaultLCID  %04Xh\n"
"GetUserDefaultLCID %04Xh"
, lcidt, lcids, lcidu);
MessageBox(0, szTmp, "GetDefaultLCID", MB_OK);
return 0;
}
Title: Re: Problem with ANSI 99 bool in windows includes
Post by: Converter on February 07, 2008, 12:42:07 AM
Results:

ThreadLocale         : 041Dh  Swedish
SystemDefaultLCID  : 0409h  English (US)
GetUserDefaultLCID : 041Dh  Swedish 

In Control Panel I have:

Regional Options tab : Swedish (decimal , instead of . etc.)
Languages tab : Language used in menu and dialogs: English
Advanced tab : Languages for non-Unicode programs: English (US)

I don't think I have a single program that shows any Swedish text
(but I know one that has menus etc. in English but the MessageBoxes
are in German!).
Title: Re: Problem with ANSI 99 bool in windows includes
Post by: TimoVJL on February 07, 2008, 05:55:21 AM
Your thread locale was swedish so Windows pick up swedish messages from pocc.exe.
If you just want use only english rip off swedish messages from pocc.exe with poide.
Title: Re: Problem with ANSI 99 bool in windows includes
Post by: Converter on February 07, 2008, 01:57:09 PM
OK, it worked. Thanks.