<div dir="ltr"><div> 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.<br>
We read that SWIG Perl can handle C++ enumerations. But, when we use the enumerations in our test.pl program:<br> <br>#!perl.exe -w<br>use strict;<br>use mdMatchupTest;<br><br>my $readwrite;<br>$readwrite = mdMatchupTestc::new_mdMUReadWrite();<br>
<br>mdMatchupTestc::mdMUReadWrite_SetLicenseString($readwrite,"LL58JH2Y");<br>mdMatchupTestc::mdMUReadWrite_SetPathToMatchUpFiles($readwrite,"C:\\MatchupAPI\\Distribution");<br>if (mdMatchupTestc::mdMUReadWrite_InitializeDataFiles($readwrite) != $mdMatchupc::mdMUReadWrite_NoError ){<br>
print( "Failed to Initialize mdMatchupTestc::mdMUReadWrite ",<br> mdMatchupTestc::mdMUReadWrite_GetInitializeErrorString($readwrite). "\n");<br>} <br><br>we get the Perl interprepter message : Name "mdMatchupc::mdMUReadWrite_NoError" used only once: possible typo at test.pl line 10<br>
Use of uninitialized value in numeric ne (!=) at test.pl line 10. </div>
<div> When we examine the mdMatchup.pm, we see that mdMatchupc::mdMUReadWrite_NoError looks like a string. An excerpt of mdMatchup.pm is shown below. </div>
<div> Is there a correct way to use SWIG packages with C++ enumerations in our perl program? Thank you.</div>
<div>-------------------------------------mdMatchup.pm---------------------------------</div>
<div>############# Class : mdMatchupTest::mdMUReadWrite ##############</div>
<div>package mdMatchupTest::mdMUReadWrite;<br>use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);<br>@ISA = qw( mdMatchupTest );<br>%OWNER = ();<br>%ITERATORS = ();<br>*NoError = *mdMatchupTestc::mdMUReadWrite_NoError;<br>
*ConfigFile = *mdMatchupTestc::mdMUReadWrite_ConfigFile;</div>
<div>-------------------------------------mdMatchup.h------------------------------------<br><font color="#0000ff" size="2">#if</font><font color="#000000" size="2"> !</font><font color="#0000ff" size="2">defined</font><font size="2"><font color="#000000">(MDMATCHUP_H)</font><br>
</font><font color="#0000ff" size="2">#define</font><font size="2"><font color="#000000"> MDMATCHUP_H</font><br></font><font color="#0000ff" size="2">#if</font><font color="#000000" size="2"> !</font><font color="#0000ff" size="2">defined</font><font size="2"><font color="#000000">(MDAPI)</font><br>
</font><font color="#808080" size="2">#if defined(_WIN32) || defined(_WIN64)<br>#define MDAPI __declspec(dllimport)<br>#else<br>#define MDAPI<br>#define __stdcall<br>#endif<br></font><font color="#0000ff" size="2">#endif</font><font size="2"><br>
</font><font color="#008000" size="2">/*<br>* C++ version of interface<br>*/<br></font><font size="2"><br></font><font color="#0000ff" size="2">class</font><font size="2"><font color="#000000"> MDAPI mdMUReadWrite</font><br>
{<br></font><font color="#0000ff" size="2">protected</font><font size="2"><font color="#000000">:</font><br></font><font color="#0000ff" size="2">struct</font><font size="2"> mdMUReadWrite_ *I;<br></font><font color="#0000ff" size="2">private</font><font color="#000000" size="2">: </font><font color="#008000" size="2">/* disable implicit constructor and assignment */<br>
</font><font size="2">mdMUReadWrite(mdMUReadWrite &X);<br>mdMUReadWrite& </font><font color="#0000ff" size="2">operator</font><font size="2">=(mdMUReadWrite &X);<br></font><font color="#0000ff" size="2">public</font><font size="2"><font color="#000000">:</font><br>
</font><font color="#0000ff" size="2">enum</font><font size="2"> ProgramStatus {<br>NoError=0,<br>ConfigFile=1,<br>LicenseExpired=2,<br>DatabaseExpired=3<br>};<br></font><font size="2"><br>mdMUReadWrite();<br>~mdMUReadWrite();<br>
<br></font><font color="#008000" size="2">/* Setup methods */<br></font><font size="2"></font><font color="#0000ff" size="2">void</font><font size="2"> SetPathToMatchUpFiles(</font><font color="#0000ff" size="2">const</font><font size="2"> </font><font color="#0000ff" size="2">char</font><font size="2"> *Path);<br>
</font><font color="#0000ff" size="2">void</font><font size="2"> SetMatchcodeName(</font><font color="#0000ff" size="2">const</font><font size="2"> </font><font color="#0000ff" size="2">char</font><font size="2"> *MatchcodeName);<br>
</font><font color="#0000ff" size="2">void</font><font size="2"> SetMatchcodeObject(mdMUMatchcode *Matchcode);<br></font><font color="#0000ff" size="2">void</font><font size="2"> SetKeyFile(</font><font color="#0000ff" size="2">const</font><font size="2"> </font><font color="#0000ff" size="2">char</font><font size="2"> *KeyFile);<br>
</font><font color="#0000ff" size="2">enum</font><font size="2"> ProgramStatus InitializeDataFiles();<br></font><font color="#0000ff" size="2">const</font><font size="2"> </font><font color="#0000ff" size="2">char</font><font size="2"> *GetInitializeErrorString();<br>
</font><font color="#0000ff" size="2">void</font><font size="2"> Initialize(</font><font color="#0000ff" size="2">void</font><font size="2">);<br></font><font color="#0000ff" size="2">int</font><font size="2"> SetLicenseString(</font><font color="#0000ff" size="2">const</font><font size="2"> </font><font color="#0000ff" size="2">char</font><font size="2">*);<br>
</font><font size="2">}<br></font><br></div></div>