Forum

> > Off Topic > c++ api programming
Forums overviewOff Topic overviewLog in to reply

English c++ api programming

2 replies
To the start Previous 1 Next To the start

old c++ api programming

omg
User Off Offline

Quote
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++)

old Re: c++ api programming

KimKat
GAME BANNED Off Offline

Quote
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!

old Re: c++ api programming

Flacko
User Off Offline

Quote
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)
edited 6×, last 07.01.13 02:46:45 pm
To the start Previous 1 Next To the start
Log in to replyOff Topic overviewForums overview