- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I continue to have problems with interfaces to C programs - I guess I just don't quite get it. I had one of our C programmers write a function to return the NIC physical address and am trying to interface with this function from my CVF code. The C header file for the function is shown below.
-----------------------------
#ifndef _GETMACNETBIOS_H
#define _GETMACNETBIOS_H
/**
* Queries the netbios for the machine Id
*
* ARGUEMENTS: An address pointer which will contain the mac id string (6bytes)
*
* RETURNS 1 if call was successful. 0 if not successful.
*/
int returnMACAddress(char *addrPtr);
#endif
---------------------------------
The following C code works fine:
---------------------------------
#include
#include "GetMACNETBIOS.h"
int main(int argc, char *argv[])
{
unsigned char macid[8];
if (returnMACAddress(macid))
printf("mac id is %02X-%02X-%02X-%02X-%02X-%02X ",macid[0],macid[1],macid[2],macid[3],macid[4],macid[5]);
else
printf("couldn't find the macid ");
}
----------------------------
But the following CVF code gives me an unresolved external:
----------------------------
program getmactest
character*6 MACAddress
integer ireturn
integer lpMACAddress
interface
integer function returnMACAddress(lpMACAddress)
integer lpMACAddress
end function
end interface
lpMACAddress = loc(MACAddress)
ireturn = returnMacAddress(lpMACAddress)
write(*,'(a6)') MACAddress
pause
end
------------------------------
The specific linker error is:
------------------------------
getmactest.obj : error LNK2001: unresolved external symbol _RETURNMACADDRESS@4
Debug/getmac.exe : fatal error LNK1120: 1 unresolved externals
------------------------------
Any suggestions would be appreciated
-----------------------------
#ifndef _GETMACNETBIOS_H
#define _GETMACNETBIOS_H
/**
* Queries the netbios for the machine Id
*
* ARGUEMENTS: An address pointer which will contain the mac id string (6bytes)
*
* RETURNS 1 if call was successful. 0 if not successful.
*/
int returnMACAddress(char *addrPtr);
#endif
---------------------------------
The following C code works fine:
---------------------------------
#include
#include "GetMACNETBIOS.h"
int main(int argc, char *argv[])
{
unsigned char macid[8];
if (returnMACAddress(macid))
printf("mac id is %02X-%02X-%02X-%02X-%02X-%02X ",macid[0],macid[1],macid[2],macid[3],macid[4],macid[5]);
else
printf("couldn't find the macid ");
}
----------------------------
But the following CVF code gives me an unresolved external:
----------------------------
program getmactest
character*6 MACAddress
integer ireturn
integer lpMACAddress
interface
integer function returnMACAddress(lpMACAddress)
integer lpMACAddress
end function
end interface
lpMACAddress = loc(MACAddress)
ireturn = returnMacAddress(lpMACAddress)
write(*,'(a6)') MACAddress
pause
end
------------------------------
The specific linker error is:
------------------------------
getmactest.obj : error LNK2001: unresolved external symbol _RETURNMACADDRESS@4
Debug/getmac.exe : fatal error LNK1120: 1 unresolved externals
------------------------------
Any suggestions would be appreciated
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My additions are bold.
-----------------------------
#ifndef _GETMACNETBIOS_H
#define _GETMACNETBIOS_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* Queries the netbios for the machine Id
*
* ARGUEMENTS: An address pointer which will contain the mac id string (6bytes)
*
* RETURNS 1 if call was successful. 0 if not successful.
*/
int returnMACAddress(char *addrPtr);
#ifdef __cplusplus
} //extern "C"
#endif
#endif //_GETMACNETBIOS_H
----------------------------
#include
#include "GetMACNETBIOS.h"
int main(int argc, char *argv[])
{
unsigned char macid[8];
if (returnMACAddress(macid))
printf("mac id is %02X-%02X-%02X-%02X-%02X-%02X ",macid[0],macid[1],macid[2],macid[3],macid[4],macid[5]);
else
printf("couldn't find the macid ");
}
----------------------------
program getmactest
character*6 MACAddress
integer ireturn
integer lpMACAddress
interface
integer function returnMACAddress(lpMACAddress)
!DEC$ATTRIBUTES C, DECORATE, ALIAS: "returnMACAddress":: returnMACAddress
integer lpMACAddress
end function
end interface
lpMACAddress = loc(MACAddress)
ireturn = returnMacAddress(lpMACAddress)
write(*,'(a6)') MACAddress
pause
end
HTH
Jugoslav
-----------------------------
#ifndef _GETMACNETBIOS_H
#define _GETMACNETBIOS_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* Queries the netbios for the machine Id
*
* ARGUEMENTS: An address pointer which will contain the mac id string (6bytes)
*
* RETURNS 1 if call was successful. 0 if not successful.
*/
int returnMACAddress(char *addrPtr);
#ifdef __cplusplus
} //extern "C"
#endif
#endif //_GETMACNETBIOS_H
----------------------------
#include
#include "GetMACNETBIOS.h"
int main(int argc, char *argv[])
{
unsigned char macid[8];
if (returnMACAddress(macid))
printf("mac id is %02X-%02X-%02X-%02X-%02X-%02X ",macid[0],macid[1],macid[2],macid[3],macid[4],macid[5]);
else
printf("couldn't find the macid ");
}
----------------------------
program getmactest
character*6 MACAddress
integer ireturn
integer lpMACAddress
interface
integer function returnMACAddress(lpMACAddress)
!DEC$ATTRIBUTES C, DECORATE, ALIAS: "returnMACAddress":: returnMACAddress
integer lpMACAddress
end function
end interface
lpMACAddress = loc(MACAddress)
ireturn = returnMacAddress(lpMACAddress)
write(*,'(a6)') MACAddress
pause
end
HTH
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks jugoslavdujic. As I said, I haven't got the details down precisely on C++ interfaces. I don't know enough about C++ and our C++ programmer doesn't know enough about Visual Fortran to do either of us any good. Anyway, it works fine...Thanks again.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page