Skip to content

Standard_Macro.hxx conflicts on Windows defines #145

Open
@dpasukhi

Description

@dpasukhi

Category

Foundation Classes

Severity

Major

Description

windows.h and #defines in Standard_Macro.hxx

Report: https://dev.opencascade.org/content/windowsh-and-defines-standardmacrohxx

We ran into a compiler error due to a conflict with Open CASCADE headers and another 3rd party component's headers. Specifically the following code in Standard_Macro.hxx caused issues in the other library until I commented these lines out. Can this be moved out of a Standard header in a future release?

// We must be careful including windows.h: it is really poisonous stuff!
// The most annoying are #defines of many identifiers that you could use in
// normal code without knowing that Windows has its own knowledge of them...
// So lets protect ourselves by switching OFF as much as possible of this in advance.
// If someone needs more from windows.h, he is encouraged to #undef these symbols
// or include windows.h prior to any OCCT stuff.
// Note that we define each symbol to itself, so that it still can be used
// e.g. as name of variable, method etc.
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN /* exclude extra Windows stuff */
#endif
#ifndef NOMINMAX
#define NOMINMAX NOMINMAX /* avoid #define min() and max() */
#endif
#ifndef NOMSG
#define NOMSG NOMSG /* avoid #define SendMessage etc. */
#endif
#ifndef NODRAWTEXT
#define NODRAWTEXT NODRAWTEXT /* avoid #define DrawText etc. */
#endif
#ifndef NONLS
#define NONLS NONLS /* avoid #define CompareString etc. */
#endif
#ifndef NOGDI
#define NOGDI NOGDI /* avoid #define SetPrinter (winspool.h) etc. */
#endif
#ifndef NOSERVICE
#define NOSERVICE NOSERVICE
#endif
#ifndef NOKERNEL
#define NOKERNEL NOKERNEL
#endif
#ifndef NOUSER
#define NOUSER NOUSER
#endif
#ifndef NOMCX
#define NOMCX NOMCX
#endif
#ifndef NOIME
#define NOIME NOIME
#endif

Expected Behavior

Standard_Macro.hxx Have no conflict definition for external usage.

Actual Behavior

Standard_Macro.hxx had windows macro redefitions

Sample Code or DRAW Tcl Script

None

Operating System

Windows

Compiler

MSVC

Compiler Version

No response

Bitness

64-bit

OCCT Version

7.8

Precise OCCT Version or Branch

No response

Environment

No response

Additional Files

https://dev.opencascade.org/content/windowsh-and-defines-standardmacrohxx

Metadata

Metadata

Assignees

No one assigned

    Labels

    1. Foundation ClassesContainers, system calls wrappers, smart pointers and other low level of OCCT code2. BugSomething isn't working5. Community

    Type

    No type

    Projects

    • Status

      Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions