Skip to content

Commit

Permalink
Export symbols for Windows DLL.
Browse files Browse the repository at this point in the history
  • Loading branch information
torque committed Feb 24, 2015
1 parent 630eb59 commit e1b581b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 32 deletions.
8 changes: 4 additions & 4 deletions precise-timer/PreciseTimerC.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#include "PreciseTimer.hpp"
#include "PreciseTimerC.h"
extern "C" {
CPT* startTimer( void ) {
EXPORT CPT* startTimer( void ) {
return reinterpret_cast<CPT*>(new PreciseTimer);
}

double getDuration( CPT *pt ) {
EXPORT double getDuration( CPT *pt ) {
return reinterpret_cast<PreciseTimer*>(pt)->getElapsedTime( );
}

unsigned int version( void ) {
EXPORT unsigned int version( void ) {
return PreciseTimer::version;
}

void freeTimer( CPT *pt ) {
EXPORT void freeTimer( CPT *pt ) {
delete reinterpret_cast<PreciseTimer*>(pt);
}
}
14 changes: 10 additions & 4 deletions precise-timer/PreciseTimerC.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
#ifndef PRECISETIMERC_H
#define PRECISETIMERC_H

#ifdef _WIN32
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif /*_WIN32*/

#ifdef __cplusplus
extern "C" {
#endif

struct CPT;
typedef struct CPT CPT;

CPT* startTimer( void );
double getDuration( CPT *pt );
unsigned int version( void );
void freeTimer( CPT *pt );
EXPORT CPT* startTimer( void );
EXPORT double getDuration( CPT *pt );
EXPORT unsigned int version( void );
EXPORT void freeTimer( CPT *pt );

#ifdef __cplusplus
}
Expand Down
24 changes: 12 additions & 12 deletions threaded-libcurl/DownloadManagerC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,55 @@

// Avoid symbol mangling.
extern "C" {
CDlM *newDM( void ) {
EXPORT CDlM *newDM( void ) {
return reinterpret_cast<CDlM*>(new DownloadManager);
}

uint addDownload( CDlM *mgr, const char *url, const char *outfile, const char *sha1) {
EXPORT uint addDownload( CDlM *mgr, const char *url, const char *outfile, const char *sha1) {
if (NULL == sha1) {
return reinterpret_cast<DownloadManager*>(mgr)->addDownload( std::string(url), std::string(outfile) );
} else {
return reinterpret_cast<DownloadManager*>(mgr)->addDownload( std::string(url), std::string(outfile), std::string(sha1) );
}
}

double progress( CDlM *mgr ) {
EXPORT double progress( CDlM *mgr ) {
return reinterpret_cast<DownloadManager*>(mgr)->getProgress( );
}

int busy( CDlM *mgr ) {
EXPORT int busy( CDlM *mgr ) {
return reinterpret_cast<DownloadManager*>(mgr)->busy( );
}

int checkDownload( CDlM *mgr, uint i ) {
EXPORT int checkDownload( CDlM *mgr, uint i ) {
return reinterpret_cast<DownloadManager*>(mgr)->checkDownload( i );
}

const char* getError( CDlM *mgr, uint i ) {
EXPORT const char* getError( CDlM *mgr, uint i ) {
return reinterpret_cast<DownloadManager*>(mgr)->getError( i );
}

void terminate( CDlM *mgr ) {
EXPORT void terminate( CDlM *mgr ) {
reinterpret_cast<DownloadManager*>(mgr)->terminate( );
}

void clear( CDlM *mgr ) {
EXPORT void clear( CDlM *mgr ) {
reinterpret_cast<DownloadManager*>(mgr)->clear( );
}

int checkFileSHA1( const char *filename, const char *expected ) {
EXPORT int checkFileSHA1( const char *filename, const char *expected ) {
return DownloadManager::checkFileSHA1( std::string( filename ), std::string( expected ) );
}

int checkStringSHA1( const char *string, const char *expected ) {
EXPORT int checkStringSHA1( const char *string, const char *expected ) {
return DownloadManager::checkStringSHA1( std::string( string ), std::string( expected ) );
}

uint version( void ) {
EXPORT uint version( void ) {
return DownloadManager::version;
}

void freeDM( CDlM* mgr ) {
EXPORT void freeDM( CDlM* mgr ) {
delete reinterpret_cast<DownloadManager*>(mgr);
}
}
Expand Down
30 changes: 18 additions & 12 deletions threaded-libcurl/DownloadManagerC.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifndef DOWNLOADMANAGERC_H
#define DOWNLOADMANAGERC_H

#ifdef _WIN32
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif /*_WIN32*/

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -9,19 +15,19 @@ struct CDlM;
typedef struct CDlM CDlM;
typedef unsigned int uint;

CDlM* newDM ( void );
uint addDownload ( CDlM *mgr, const char *url,
EXPORT CDlM* newDM ( void );
EXPORT uint addDownload ( CDlM *mgr, const char *url,
const char *outfile, const char *sha1 );
double progress ( CDlM *mgr );
int busy ( CDlM *mgr );
int checkDownload ( CDlM *mgr, uint i );
const char* getError ( CDlM *mgr, uint i );
void terminate ( CDlM *mgr );
void clear ( CDlM *mgr );
int checkFileSHA1 ( const char *filename, const char *expected );
int checkStringSHA1( const char *string, const char *expected );
uint version ( void );
void freeDM ( CDlM *mgr );
EXPORT double progress ( CDlM *mgr );
EXPORT int busy ( CDlM *mgr );
EXPORT int checkDownload ( CDlM *mgr, uint i );
EXPORT const char* getError ( CDlM *mgr, uint i );
EXPORT void terminate ( CDlM *mgr );
EXPORT void clear ( CDlM *mgr );
EXPORT int checkFileSHA1 ( const char *filename, const char *expected );
EXPORT int checkStringSHA1( const char *string, const char *expected );
EXPORT uint version ( void );
EXPORT void freeDM ( CDlM *mgr );

#ifdef __cplusplus
}
Expand Down

0 comments on commit e1b581b

Please sign in to comment.