Re: Ver 4.0 ifdef question

new topic     » goto parent     » topic index » view thread      » older message » newer message
euphoric said...

You would have to set a variable, probably... or use platform(), even though it's deprecated.

**STOP STOP STOP** News Flash: The platform() function is not, repeat, not being deprecated or removed.

euphoric said...

Something like:

integer myOS = UnknownOS 
 
ifdef WIN32 then 
  myOS = Win32 
else 
  myOS = Linux 
else 
  myOS = FreeBSD 
else 
  myOS = MacOSX 
end if 

Ok, now suppose one does this. What are you going to do with myOS? Maybe something like ...

if myOS = WIN32 then 
    puts(1, "Breaking Windows\n") -- Something that must only run in Windows 
else 
    puts(1, "Chasing penguins\n") -- Something that must only run in 'nix 
end if 

This would cause a run-time test of the myOS variable each time. Using ifdef instead would generate smaller IL code and run faster.

ifdef WIN32 then 
    -- On 'nix boxes, this does not generate any IL. 
    puts(1, "Breaking Windows\n") -- Something that must only run in Windows 
else 
    -- On Windows boxes, this does not generate any IL. 
    puts(1, "Chasing penguins\n") -- Something that must only run in 'nix 
end ifdef 

I know which option I'd choose. blink

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu