Swig Perl C++ enumeration issue

Frank Chang frankchang91 at gmail.com
Tue Sep 30 13:33:04 PDT 2008


      Hi, We are trying to use SWIG 1.3.36 with perl  5.8.8 and the Visual
Studio C++ 2005 compiler. The header file used in our mdMatchup.i file is
shown below. In our mdMatchup.i , we are using the module mdMatchupTest. We
ran swig -c++ -perl mdMatchup.i and obtained mdMatchup.pm and
mdMatchup_wrap.cxx.
       We read that SWIG Perl can handle C++ enumerations. But, when we use
the enumerations in our test.pl program:

#!perl.exe -w
use strict;
use mdMatchupTest;

my $readwrite;
$readwrite = mdMatchupTestc::new_mdMUReadWrite();

mdMatchupTestc::mdMUReadWrite_SetLicenseString($readwrite,"LL58JH2Y");
mdMatchupTestc::mdMUReadWrite_SetPathToMatchUpFiles($readwrite,"C:\\MatchupAPI\\Distribution");
if (mdMatchupTestc::mdMUReadWrite_InitializeDataFiles($readwrite) !=
$mdMatchupc::mdMUReadWrite_NoError ){
 print( "Failed to Initialize mdMatchupTestc::mdMUReadWrite ",
  mdMatchupTestc::mdMUReadWrite_GetInitializeErrorString($readwrite). "\n");
}

we get the Perl interprepter message : Name
"mdMatchupc::mdMUReadWrite_NoError" used only once: possible typo at test.pl
line 10
Use of uninitialized value in numeric ne (!=) at test.pl line 10.
  When we examine the mdMatchup.pm,  we see that
mdMatchupc::mdMUReadWrite_NoError looks like a string. An excerpt of
mdMatchup.pm is shown below.
  Is there a correct way to use SWIG packages with C++ enumerations in our
perl program? Thank you.
-------------------------------------mdMatchup.pm---------------------------------
############# Class : mdMatchupTest::mdMUReadWrite ##############
package mdMatchupTest::mdMUReadWrite;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( mdMatchupTest );
%OWNER = ();
%ITERATORS = ();
*NoError = *mdMatchupTestc::mdMUReadWrite_NoError;
*ConfigFile = *mdMatchupTestc::mdMUReadWrite_ConfigFile;
-------------------------------------mdMatchup.h------------------------------------
#if !defined(MDMATCHUP_H)
#define MDMATCHUP_H
#if !defined(MDAPI)
#if defined(_WIN32) || defined(_WIN64)
#define MDAPI __declspec(dllimport)
#else
#define MDAPI
#define __stdcall
#endif
#endif
/*
* C++ version of interface
*/

class MDAPI mdMUReadWrite
{
protected:
struct mdMUReadWrite_ *I;
private: /* disable implicit constructor and assignment */
mdMUReadWrite(mdMUReadWrite &X);
mdMUReadWrite& operator=(mdMUReadWrite &X);
public:
enum ProgramStatus {
NoError=0,
ConfigFile=1,
LicenseExpired=2,
DatabaseExpired=3
};

mdMUReadWrite();
~mdMUReadWrite();

/* Setup methods */
void SetPathToMatchUpFiles(const char *Path);
void SetMatchcodeName(const char *MatchcodeName);
void SetMatchcodeObject(mdMUMatchcode *Matchcode);
void SetKeyFile(const char *KeyFile);
enum ProgramStatus InitializeDataFiles();
const char *GetInitializeErrorString();
void Initialize(void);
int SetLicenseString(const char*);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/miltonkeynes-pm/attachments/20080930/293d10a9/attachment.html>


More information about the MiltonKeynes-pm mailing list