Is there any macros in DarkGDK like this:

#ifdef __DARKGDK_WINDOWS
        #include "MY_WINDOWS_HEADER.h"
#else
        #include "MY_LINUX_HEADER.h"
#endif

any help would be appreciated, thanks in advance!

Dani AI

Generated

Short answer: don’t rely on a library-specific symbol unless you can find it in the DarkGDK headers. A simpler, more portable approach is to use the compiler/platform macros or to define your own project macro.

As suggested, search the DarkGDK headers for any library-defined macro first. If Explorer’s indexed search failed (as you reported), use Visual Studio’s Find in Files (Ctrl+Shift+F) pointed at the DarkGDK include folder, or run a command-line search from that folder. Examples you can run in a shell:

findstr /S /I /M "DARKGDK" *.h
grep -RIn --include="*.h" "DARKGDK" .

If you don’t find a DarkGDK-specific macro, use the standard platform macros provided by compilers. Common ones are _WIN32 (Windows), __linux__ (Linux) and __APPLE__ (macOS). For portability, put platform-specific includes behind those checks.

If you want explicit control, define a project-level symbol and test it in code. In Visual Studio add a name under Project → Properties → C/C++ → Preprocessor → Preprocessor Definitions; in a Makefile or gcc command line add -DMY_PROJECT_WINDOWS. Then guard your headers with that symbol.

To inspect what the compiler already defines, dump preprocessor macros (GCC example):

gcc -dM -E - < /dev/null

A couple of practical notes: _WIN32 is defined on both 32- and 64-bit Windows; command-line searches avoid Windows indexing problems; and ’s suggestion to scan files from the shell is a good idea — the findstr/grep examples above are simpler one-liners you can copy and run.

Recommended Answers

All 6 Replies

Maybe, why not do a search for #ifdef on all the library header files?

how do i do that?

How?

Right-click on a folder, select search ....
This is easy, you should know this already.

How?

Right-click on a folder, select search ....
This is easy, you should know this already.

It says the search can not be completed because the folder is not indexed?

go to a dos prompt (start, run, cmd) go to your DarkGDK include folder (cd \program files\DarkGDK\Include) probably, and do for %x in (*) do type %x | find /i "#define" >>c:\outputfile.txt . Then, double click my computer, double click C: drive, double click "outputfile.txt", and read it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.