Forum

> > Off Topic > c++ api programming
ForenübersichtOff Topic-ÜbersichtEinloggen, um zu antworten

Englisch c++ api programming

2 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt c++ api programming

omg
User Off Offline

Zitieren
i was just wondering if anyone here is experienced with this because i wanted to get into it (i already know a lot of c++)

alt Re: c++ api programming

KimKat
GAME BANNED Off Offline

Zitieren
I know some C, C++ but I can't say that I'm a expert at it while I do know how to compile programs without getting dependency hell alot more than necessary using either of the IDE's out there, namely CodeBlocks or DevC++.

Here's a link to a YouTube clip that can teach you more about API programming. I hope that helps, else ask me any other questions regarding C++ and have a merry christmas user omg!

alt Re: c++ api programming

Flacko
User Off Offline

Zitieren
Create a DLL project using your favorite IDE

Throw this preprocessor lines somewhere in your main header
1
2
3
4
5
#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport) //SHOW IN DLL
#else
#define DLL_EXPORT __declspec(dllimport) //READ FROM DLL
#endif
if you're using linux:
1
2
3
4
5
#ifdef BUILD_DLL
#define DLL_EXPORT __attribute__((visibility("default"))) //SHOW IN SO
#else
#define DLL_EXPORT //DO NOTHING
#endif
Ofc, you can merge both snippets to make your shared library compatible with both DSO syntaxes:
1
2
3
4
5
6
#ifdef __WIN32__
//wincode
#endif
#ifdef __linux__
//linuxcode
#endif

Now declare all your classes, structs and functions like this:
1
[class/struct/returntype] DLL_EXPORT [objectname]
Enums and namespace don't need this as they are declared and defined in headers.

Add BUILD_DLL as a #define in your project and build it.
Now you can set up your own library using the resulting .dll and .lib files (plus your header files, of course)
In case you built a linux .so, that's all you get (and all you need)
6× editiert, zuletzt 07.01.13 14:46:45
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antwortenOff Topic-ÜbersichtForenübersicht