Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error C2059

Status
Not open for further replies.

sweep123

Technical User
May 1, 2003
185
GB
I need to modify a library that is used by a C-Scripting application to allow a MFC application to stop and start the processing.

However I get the compiler error C2059 at the code snip below:-

#define DLLDIR __declspec(dllexport) // export DLL information

// The extern "C" declaration allows mixed languages compactability, it prevents
// the C++ compiler from using decorated (modified) names for the functions
extern "C" { <-------- Error here !!!!!!!!!!!
void DLLDIR SetAbortFlag(int);
int DLLDIR GetAbortFlag(void);
};
static int abortFlag; /* The flag to abort the test */
static int contiuneFlag; /* The flag to schedule the test to continue */
static int enterFlag; /* The flag to schedule data entry the test */


int APPGetAbortFlag()
{
return abortFlag;
}

void APPSetAbortFlag(int a)
{
if(a == 1)
abortFlag = 1;
else
abortFlag = 0;
}
 
I got it built but hit another problem!

The abortFlag is always 0 (false); see code snips below:-


First the Modifed section of th DLL project:-

#define DLLDIR __declspec(dllexport) // export DLL information

// The extern "C" declaration allows mixed languages compactability, it prevents
// the C++ compiler from using decorated (modified) names for the functions
extern "C" { <-------- Error here !!!!!!!!!!!
void DLLDIR APPSetAbortFlag(int);
int DLLDIR APPGetAbortFlag(void);
};
static int abortFlag; /* The flag to abort the test */
static int contiuneFlag; /* The flag to schedule the test to continue */
static int enterFlag; /* The flag to schedule data entry the test */


int APPGetAbortFlag()
{
return abortFlag;
}

void APPSetAbortFlag(int a)
{
if(a == 1)
abortFlag = 1;
else
abortFlag = 0;
}

Next the section of code for the application that uses the DLL:-

typedef void (*APPSETABORTFLAG)(int); // Pointer to APPSetAbortFlag(int)
typedef int (*APPGETABORTFLAG)(void); // Pointer to function int APPGetAbortFlag()

hMod = LoadLibrary("WHLLib.dll");

pGetAbortFlag = (APPGETABORTFLAG) GetProcAddress(hMod, "APPGetAbortFlag");

pSetAbortFlag = (APPSETABORTFLAG) GetProcAddress(hMod, "APPSetAbortFlag");

I set the flag like:-
UINT value = 1;
(pSetAbortFlag)(value);

and read the flag like:-

int result = (pGetAbortFlag) ();

Are they a problem with the use of the item of data in the DLL?


 
how aboud #ifdef __cplusplus? If you don't put this flag then in C compilling you will get error.

Ion Filipski
1c.bmp
 
OK, thanks. I fiddled around with some of the complier options and got it complied.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top