How do I check OS with a preprocessor directive?

前端 未结 16 1528
星月不相逢
星月不相逢 2020-11-22 13:53

I need my code to do different things based on the operating system on which it gets compiled. I\'m looking for something like this:

#ifdef OSisWindows
// do         


        
16条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 14:13

    Just to sum it all up, here are a bunch of helpful links.

    • GCC Common Predefined Macros
    • SourceForge predefined Operating Systems
    • MSDN Predefined Macros
    • The Much-Linked NaudeaSoftware Page
    • Wikipedia!!!
    • SourceForge's "Overview of pre-defined compiler macros for standards, compilers, operating systems, and hardware architectures."
    • FreeBSD's "Differentiating Operating Systems"
    • All kinds of predefined macros
    • libportable

提交回复
热议问题