0

I am working in two different versions of c++ (builder 2009 and XE1). In both I need to use the same file f.cpp, which contains function LoadLibrary("path"). Builder 2009 requires path of type char and XE1 - wchar, so this invokes error.

Is there some way to use "LoadLibrary()" with both char&wchar?

tanks.

Onic
  • 11
  • 1

2 Answers2

3

Use the type TCHAR that is either wchar or char depending on the macro _UNICODE.

Ivaylo Strandjev
  • 69,226
  • 18
  • 123
  • 176
0

You can use the preprocessor for this, using the #if defined functionality to decide which to use:

#if defined(__SOME_SPECIAL_DEFINE_FOR_ONE_COMPILER__)
LoadLibrary("path");
#elif defined(__SOME_OTHER_SPECIAL_DEFINE_FOR_OTHER_COMPILER__)
LoadLibrary(L"path");
#else
# error unknown compiler
#endif
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621