NO

Author Topic: Can't compile windows.h under x64  (Read 9350 times)

GypsyPrince

  • Guest
Can't compile windows.h under x64
« on: May 16, 2014, 07:36:23 AM »
Hello All!
I wrote a small Hello World! program that of course, displays "Hello World!" to the console screen. Just to tinker a bit I added a few more messages which are separated by a pause function and a clear screen function, the latter of which makes a call to the Windows API and uses the windows.h header. When I compile my app as a 32-bit console program it compiles and works perfectly. However, when I try to build it as a 64-bit console app I get the following errors: 

====================================================================================
Building tutorial_03.obj.
C:\Program Files\PellesC\Include\Win\winnt.h(9034): warning #1001: Unterminated #if/#ifdef/#ifndef in #include file.
C:\Program Files\PellesC\Include\Win\winbase.h(258): error #2048: Undeclared identifier 'RTL_CRITICAL_SECTION' (did you mean 'LPFILETIME'?).
C:\Program Files\PellesC\Include\Win\winbase.h(259): error #2048: Undeclared identifier 'PRTL_CRITICAL_SECTION' (did you mean 'CRITICAL_SECTION'?).
C:\Program Files\PellesC\Include\Win\winbase.h(260): error #2048: Undeclared identifier 'PRTL_CRITICAL_SECTION' (did you mean 'PCRITICAL_SECTION'?).
C:\Program Files\PellesC\Include\Win\winbase.h(262): error #2048: Undeclared identifier 'RTL_CRITICAL_SECTION_DEBUG' (did you mean 'LPCRITICAL_SECTION'?).
C:\Program Files\PellesC\Include\Win\winbase.h(263): error #2048: Undeclared identifier 'PRTL_CRITICAL_SECTION_DEBUG' (did you mean 'CRITICAL_SECTION_DEBUG'?).
C:\Program Files\PellesC\Include\Win\winbase.h(264): error #2048: Undeclared identifier 'PRTL_CRITICAL_SECTION_DEBUG' (did you mean 'PCRITICAL_SECTION_DEBUG'?).
C:\Program Files\PellesC\Include\Win\winbase.h(268): error #2048: Undeclared identifier 'RTL_RUN_ONCE' (did you mean 'LPRECT'?).
C:\Program Files\PellesC\Include\Win\winbase.h(269): error #2048: Undeclared identifier 'PRTL_RUN_ONCE' (did you mean 'INIT_ONCE'?).
C:\Program Files\PellesC\Include\Win\winbase.h(270): error #2048: Undeclared identifier 'PRTL_RUN_ONCE' (did you mean 'PINIT_ONCE'?).
C:\Program Files\PellesC\Include\Win\winbase.h(292): error #2048: Undeclared identifier 'RTL_SRWLOCK' (did you mean 'LPCRECT'?).
C:\Program Files\PellesC\Include\Win\winbase.h(301): error #2048: Undeclared identifier 'BOOLEAN' (did you mean 'BOOL'?).
C:\Program Files\PellesC\Include\Win\winbase.h(302): error #2048: Undeclared identifier 'BOOLEAN' (did you mean 'BOOL'?).
C:\Program Files\PellesC\Include\Win\winbase.h(304): error #2048: Undeclared identifier 'RTL_CONDITION_VARIABLE' (did you mean 'LPINIT_ONCE'?).
C:\Program Files\PellesC\Include\Win\winbase.h(650): error #2078: Invalid struct field declarations.
C:\Program Files\PellesC\Include\Win\winbase.h(650): error #2001: Syntax error: expected '}' but found 'EXCEPTION_RECORD'.
C:\Program Files\PellesC\Include\Win\winbase.h(650): warning #2014: Empty declaration.
C:\Program Files\PellesC\Include\Win\winbase.h(652): error #2156: Unrecognized declaration.
C:\Program Files\PellesC\Include\Win\winbase.h(652): error #2048: Undeclared identifier 'EXCEPTION_DEBUG_INFO' (did you mean 'EXCEPTION_DISPOSITION'?).
C:\Program Files\PellesC\Include\Win\winbase.h(652): error #2001: Syntax error: expected ';' but found ','.
C:\Program Files\PellesC\Include\Win\winbase.h(652): warning #2099: Missing type specifier; assuming 'int'.
C:\Program Files\PellesC\Include\Win\winbase.h(710): error #2078: Invalid union field declarations.
C:\Program Files\PellesC\Include\Win\winbase.h(710): error #2001: Syntax error: expected '}' but found 'EXCEPTION_DEBUG_INFO'.
C:\Program Files\PellesC\Include\Win\winbase.h(710): error #2065: Invalid use of incomplete type '(incomplete) union (no name)'.
C:\Program Files\PellesC\Include\Win\winbase.h(711): error #2199: Invalid field declaration after empty field in '(incomplete) struct _DEBUG_EVENT'.

If you are compiling a Windows program, make sure you use the /Ze option!
*** Error code: 1 ***
Done.
====================================================================================

The number of errors is actually over 100. I just shortened them here for space and they all refer to winbase.h.  Here is my current congiuration when trying to compile an x64 console app.

COMPILER
------------------------------------------------------------------------------------------
Runtime Library: Single-threaded (LIB)
Calling conv: _fascal (is grayed out and won't let me select a different one)
Machine: x64
Lining: Default
C Standard: C11
Options: Enable Microsoft Extensions = checked\Enable Pelle's C Extensions = checked
CCFLAGS: -std:C11 -Tx64-coff -Ot -Ob1 -fp:precise -W1 -Gd -Ze -Zx

LINKER
------------------------------------------------------------------------------------------
Library and object files: kernel32.lib advapi32.lib delayimp64.lib
Subsystem Type: Console
Machine: x64

My code is insignificant to the error produced. If I have only one line of code such as

printf("Hello World!\n)";

without calling the 'pause' or 'clrscrn' functions and I still get the same errors simply by having #include <windows.h> in my directives and compiling it as an x64 console app. When I compile it as an x86 console app, all works well.

Am I missing a necessary compiler switch or setting somwhere for x64 compilation that I'm not aware of?

Thanks in advance!!!



INFO UPDATE:
I forgot to mention earlier that I'm using the new version 8.00.7 RC3.  Is there any chance this might be a minor bug with the pre-defined compiler settings not agreeing with the windows header files supplied with Pelle's C?

I have since tried the exact same code compiled to x64 in Code::Blocks using the MinGW compiler, in C++Builder XE6, and in Visual C++ 2013. It worked flawlessly with all three but I really like Pelle's C a lot better than those, so I want to tried and get this solved ASAP...
« Last Edit: May 18, 2014, 08:48:49 AM by GypsyPrince »

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Can't compile windows.h under x64
« Reply #1 on: May 19, 2014, 05:40:30 AM »
Please use the "ZIP project files" option of the IDE and post a sample project here...

Ralf

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Can't compile windows.h under x64
« Reply #2 on: May 20, 2014, 06:46:00 AM »
Well, I do not get that list of error messages that you posted in your first post, just one about _fastcall/_cdecl mismatch.

Created a new 64bit console project, added your .c and .h file to it and it compiles ok, just doesn't clear the screen even though the cursor does get repositioned.

Don't have time for further tests tonight as I have to call it a night in a few minutes as I have a long day tomorrow, but will likely tomorrow night or on Wednesday morning to play a little bit more with it...

Ralf

GypsyPrince

  • Guest
Re: Can't compile windows.h under x64
« Reply #3 on: May 20, 2014, 08:18:21 AM »
I was hoping you would compile it using the project file that I had created, to perhaps to if the default compiler settings for version 8.00.7 RC3 might be different or incorrect. I'm not sure if the issue is with the default compiler setting or with the header files that cam with this version...

JohnF

  • Guest
Re: Can't compile windows.h under x64
« Reply #4 on: May 20, 2014, 10:29:38 AM »
I compiled and ran your project without problems.

John

GypsyPrince

  • Guest
Re: Can't compile windows.h under x64
« Reply #5 on: May 20, 2014, 02:02:01 PM »
What version of Pelle's C are you using?

JohnF

  • Guest
Re: Can't compile windows.h under x64
« Reply #6 on: May 20, 2014, 02:29:31 PM »
8 RC 3

John

GypsyPrince

  • Guest
Re: Can't compile windows.h under x64
« Reply #7 on: May 20, 2014, 08:27:49 PM »
PROBLEM FINALLY SOLVED!!!  ;D ;D ;D

I performed yet another uninstall and this time did a re-install by running the installation program as Administrator. Everything compiles perfectly now and the resulting executables work. I'm not sure what difference that made in the installation process or what settings it allowed Pelles to make regarding x64 compilation and\or write access different than when it was initially installed without adminstrator privileges. But I do know the way Windows 8.1 locks everything down for security it can be very finicky about what programs are allowed to do.  When I first installed this version of Windows I had to create a context menu item linked to my registry to where I could take ownership of my own freakin' folders before Windows would allow me to access them or write to them. I appreciate 8.1's extra security but it can be a real pain in the a** sometimes.

Sincere thanks and graditude to everyone who helped out and looked into this for me!!!
« Last Edit: May 20, 2014, 08:29:46 PM by GypsyPrince »

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Can't compile windows.h under x64
« Reply #8 on: May 21, 2014, 05:09:03 AM »

GypsyPrince

  • Guest
Re: Can't compile windows.h under x64
« Reply #9 on: May 21, 2014, 05:57:12 AM »
Thanks for your help, John and Ralf!! Something wasn't getting installed correctly, possibly a registry setting or folder acces (I'm not sure) until I ran the installation program as an Administrator. I've had similar problems with my CAD and engineering software installed under Windows 8.1 and it's overbearing security, but the thought of Pelles C having the same issue never crossed my mind until late yesterday afternoon. All is working well now...

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Can't compile windows.h under x64
« Reply #10 on: May 21, 2014, 10:23:57 PM »
Glad to hear that you found the issue.

Ralf  ;)