Do you mean, how does a C object file that has been linked into a C++ project, retrieve/accept the GUID of an object?
gerard4143
Nearly a Posting Maven
2,295 posts since Jan 2008
Reputation Points: 512
Solved Threads: 397
Skill Endorsements: 0
I know how to solve this in Linux using GCC but the solution is not portable...That said you should be able to use the concept which is....wrapping the C++ functionality in a C calling sequence, see below
testit.cpp
#include <iostream>
extern "C" void PrintStr(char *str);
void PrintStr(char *str)
{
std::cout << "From Cpp Object file->" << str << std::endl;
}
testit.h
void PrintStr(char *str);
test.c
#include "testit.h"
int main()
{
char ch[] = "From the C program";
PrintStr(ch);
return 0;
}
And my compile lines
g++ -Wall -ansi -pedantic -c testit.cpp
gcc testit.o test.c -o test -Wall -ansi -pedantic -lstdc++
Note the inclusion of the standard C++ library with the -lstdc++ switch..Hope this helps.
Output:
From Cpp Object file->From the C program
gerard4143
Nearly a Posting Maven
2,295 posts since Jan 2008
Reputation Points: 512
Solved Threads: 397
Skill Endorsements: 0