Using VS 2008 Have a C++ class in which I'm calling functions from a 3rd party dll. The definition in the header file is as follows:
namespace OITImageExport
{
class ImageExport
{
private:
SCCERR seResult; /* Error code returned. */
VTHDOC hDoc; /* Input doc handle returned by DAOpenDocument(). */
VTHEXPORT hExport; /* Handle to the export returned by EXOpenExport(). */
VTDWORD dwFIFlags; /* Used in setting the SCCOPT_FIFLAGS option. */
VTCHAR szError[256]; /* Error string buffer. */
VTDWORD dwOutputId; /* Output Format. */
VTDWORD dwSpecType;
public:
ImageExport(const char* outputId, const char* specType);
void ProcessDocument(const char* inputPath, const char* outputPath);
~ImageExport();
};
}
In the constructor I initialize two of the class fields having values which come from enumerations in the 3rd party dll:
ImageExport::ImageExport(const char* outputId, const char* specType)
{
if(outputId == "jpeg")
{
dwOutputId = FI_JPEGFIF;
}
if(specType == "ansi")
{
dwSpecType = IOTYPE_ANSIPATH;
}
seResult = DAInit();
if (seResult != SCCERR_OK)
{
DAGetErrorString(seResult, szError, sizeof(szError));
fprintf(stderr, "DAInit() failed: %s (0x%04X)\n", szError, seResult);
exit(seResult);
}
}
When I use this class inside of a console app, with a main method in another file (all in the same namespace), instantiating the class object and calling the methods, it works like a champ. So, now that I know the basic code works, I open a dll project using the class header and code file. Course I have to add the dll macro, namely:
#ifdef IMAGEDLL_EXPORTS
#define DLL __declspec(dllexport)
#else
#define DLL __declspec(dllimport)
#endif
and changed the class definition to "class DLL ImageExport". Compiled nicely to a dll and .lib file (No errors, No warnings). Now to test this dll I open another console project using the same main method as before and linking to the (dll) lib file. Had problems, which when tracked down were the result of the two fields not being set; both had values of 0. Went back to the first console app and printed out the values: dwOutputId was 1535 (#define FI_JPEGFIF 1535) and dwSpecType was 2 (#define IOTYPE_ANSIPATH 2).
Now if I was assigning these values outside of the class, I can see how the visibility could be different, but why is the assignment in the dll not working? Is it something about having a class in the dll?