It is possible to turn of Windows API constants?

Advanced game related topics
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

It is possible to turn of Windows API constants?

Post by Lebostein »

I am using Mac OS to write my code. And now I am trying to compile it with Windows. The problem is: I use some names that are reserved for Windows constants and structures. Can I turn of including windows API and constants?
Fred
Administrator
Administrator
Posts: 16617
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: It is possible to turn of Windows API constants?

Post by Fred »

you can move the windows.res out of the resident folder and it should do the trick
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: It is possible to turn of Windows API constants?

Post by PB »

It's better in the long run just to rename your constants,
instead of messing around with the PureBasic installation.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: It is possible to turn of Windows API constants?

Post by ts-soft »

Code: Select all

CompilerIf Not Defined(WM_CLOSE, #PB_Constant)
  #WM_CLOSE = 16
CompilerEndIf
...
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: It is possible to turn of Windows API constants?

Post by Shield »

That won't fix his problem...
He's talking about that he defined his own constants and structures that conflict with WinAPI names.

------

Maybe you can just prefix your identifiers? I agree with PB, messing with plain
PB installations is not a good solution and it makes the code much less portable.
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: It is possible to turn of Windows API constants?

Post by luis »

Lebostein wrote:I am using Mac OS to write my code. And now I am trying to compile it with Windows.
So your target is now Windows and not OSX. Change your code accordingly to the new platform or better yet to both, and/or use conditional compilation if required.
Trying to force your way in eradicating what's already natively defined in PB for a specific platform does look a very bad idea to me and it will come back to bite you sooner or later. This if you plan to reuse the code, to share it with someone else, etc.
If you just want to get an EXE right now I suppose Fred 's solution is just what you want.
"Have you tried turning it off and on again ?"
A little PureBasic review
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: It is possible to turn of Windows API constants?

Post by IdeasVacuum »

It would be easier to re-name your constants etc. uniquely ~ #Lebostein_WM_CLOSE will not be found on any OS.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: It is possible to turn of Windows API constants?

Post by Mistrel »

You should probably try to adapt your code around it. You may find the need to use some Win32 voodoo to get everything to run smoothly and then you'll be in trouble!
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

Re: It is possible to turn of Windows API constants?

Post by Lebostein »

Can I add all win constants and structs to the mac version? With this way the mac compiler should warn me if I use reserved things.
Post Reply