Re: linux app to windows

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Victor Bazarov wrote:
Kyle wrote:
I have been given the task of trying to migrate a linux app that one of the other admins wrote to windows. The source code is basically straight C with a few small issues, most of which are easily fixed. I have one question: Is there any way to have an if statement like this:
if compiling on linux
define strlwr(...,...)
end if

As you can see linux doesn't have a strlwr function so I need to define it, but windows has one. The goal is to allow the app to compile on both linux and windows so having the if wrapper would greatly help. All the app does is read in a file, flip somethings around, and write out a new file.

I think you're looking for a preprocessor directive for conditional compilation. Something like

#ifndef WIN32
#define strlwr(...,...)
#endif

Yes? No? Did I guess right? See the compiler documentation that would explain what preprocessor macros are pre-defined for you and look for something that would identify the target OS. I don't know what a Linux compiler would have defined if the target OS is Linux. But it would probably have "linux" in the name...

GCC?

V

Schobi
.



Relevant Pages

  • Re: Anti Virus, now Anti Spy-ware
    ... Windows will not remain an easy target. ... serious increase in your credit card balance---without even touching Linux. ... as popular too" crowd doesn't seem to understand. ...
    (Ubuntu)
  • Re: Why is it dangerous?
    ... When I compile a program from our C course with a windows compiler ... Is linux more dangerous than windows? ... to the first character in a buffer, and stores an entire line from stdin ...
    (comp.lang.c)
  • Re: C++ with VS.NET and Twilight of the Microsoft Era
    ... this has to do diddly squat with the compiler used to compile ... VC6 is of the same generation. ... Most of the time we use the best tool for the job, and on windows, VC++ is ... tried to use GDB and DDD on linux to debug multithreaded frameworks. ...
    (microsoft.public.vc.language)
  • Re: Einsteig in Microcontroller und Programmierung
    ... Linux Format nix anfangen kann. ... Problem und der Ignoranz von anderen Systemen für Quellcode Änderungen ... Und wenn ein Compiler abkackt, weil er ohne CR nicht leben kann, ist der ... Unter Windows konzernweit entwickelt und compiliert. ...
    (de.sci.electronics)
  • Re: Settle a Bet
    ... with a Linux compiler, or it could be compiled to run in ... with a Windows compiler. ... platform will understand. ...
    (comp.lang.c)