1 Quelltext - dllexport - shared library

Post Reply
Message
Author
mandeltuete
Posts: 4
Joined: 22. Aug 2002 21:59
Location: Neuhausen am Rheinfall
Contact:

1 Quelltext - dllexport - shared library

#1 Post by mandeltuete »

Hallo!

Ich habe folgendes Denkproblem:
Ich möchte Funktionen mit __declspec(dllexport) unter Windows, und mit einer Shared Library unter Linux exportieren.

Das heisst:
Unter Windows sollte die Funktion so aussehen:
__declspec(dllexport) int IchbineineFunktion(int i); [oder mit {}]

Unter Linux aber nur so:
int IchbineineFunktion(int i);

Vor jede Funktion ein #ifndef, etc. hinzuschreiben ist mir zu umständlich.

Gibt es da eine andere Möglichkeit?


Danke für eure Hilfe im Vorraus!
Serge

tkortkamp
Posts: 143
Joined: 08. Apr 2001 22:56
Location: Bremen

Re: 1 Quelltext - dllexport - shared library

#2 Post by tkortkamp »

Jap. So:
<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
#ifdef WIN32
_declspec(dllexport) int IchbineineFunktion(int i);
_declspec(dllexport) int IchbineineandereFunktion(int i);
#else
int IchbineineFunktion(int i);
int IchbineineandereFunktion(int i);
#endif
</font><hr></pre></blockquote>

Weiß jetzt aber nicht ob das Makro dafür WIN32 ist, aber das weißt du ja bestimmt <img src="http://www.pl-forum.de/UltraBoard/Images/Wilk.gif" border="0" align="middle">

c ya,
Tobias
Last edited by tkortkamp on 24. Aug 2002 15:14, edited 2 times in total.
dude i'm pretty damn sure you could script somebody back to life

Udo Maslo

Re: 1 Quelltext - dllexport - shared library

#3 Post by Udo Maslo »

Unter nicht-Win irgendwo global (Makefile) leer definieren

<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
// ? WIN32, vieleicht auch _BORLAND_ , _BILL_G_ oder ähnlich ?
#ifndef WIN32
#define __declspec(dllexport)
#endif

/* schadet nicht */
_declspec(dllexport) int main()
{
puts( "Hallo!" );
return( 0 );
}
</font><hr></pre></blockquote>

Udo Maslo

Re: 1 Quelltext - dllexport - shared library

#4 Post by Udo Maslo »

Einen Unterstrich mehr oder weniger ... (Falls jemand cuttet und pastet)

mandeltuete
Posts: 4
Joined: 22. Aug 2002 21:59
Location: Neuhausen am Rheinfall
Contact:

Re: 1 Quelltext - dllexport - shared library

#5 Post by mandeltuete »

Hmm, das von Tobias hät ich auch selber draufkommen können. Aber: Dann muss ich alles doppelt machen, funktionsrümpfe, etc!

@Udo Maslo:
Also ignoriert Linux das __declespec(dllexport)?
Kannst du das mit dem #define __declspec(dllexport) und mit dem #define [leer] nochmals erklären? Das hab ich ned ganz verstanden..

Danke für eure Hilfe!
Serge

Udo M.

Re: 1 Quelltext - dllexport - shared library

#6 Post by Udo M. »

Na so, einfach nichts hinschreiben:
#define __declspec(dllexport)
Also nicht so:
#define __declspec(dllexport) Hier steht, bei der Definition dieses Makros, was die Windows-Compiler machen

Klaro?

Post Reply