C linkage problem with ACE on windows

  • Thread starter martinbriefcase
  • Start date
M

martinbriefcase

Compiling a program using ACE + MSVC++8, got lots of errors and some
are listed as below:

Error 2 error C2894: templates cannot be declared to have 'C'
linkage c:\program files\microsoft visual studio
8\vc\include\iosfwd 39
Error 39 error C2733: second C linkage of overloaded function
'ACE_OS::atoi' not
allowed c:\tmp\ace+tao+ciao\ace_wrappers\ace\os_ns_stdlib.h 79
Error 41 error C2733: second C linkage of overloaded function
'ACE_OS::getenv' not
allowed c:\tmp\ace+tao+ciao\ace_wrappers\ace\os_ns_stdlib.h 116
...
...
When i changed #include <string> to #include <string.h> i got no errors
concerning iosfwd but the rest don't go away.
The config.h of ACE contains the following line:
#define ACE_HAS_STANDARD_CPP_LIBRARY 1
#include "ace/config-win32.h"
The version of ACE is Release,v 4.13 2005/08/05

It can be compiled on Linux/Unix and I suspect there is something wrong
with the installation of ACE. Does anyone has experienced the
same/similar problem before????
 
M

martinbriefcase

I cleaned all the object files and rebuilt again and this time i got
different errors. The following code is the fragement of the whole
AmmUtils.h file and can anyone be kind to tell me what's wrong with my
code?

Error 13 error C2062: type 'int'
unexpected c:\working\qommessage\qommessage\ammutils.h 14
Error 14 error C2334: unexpected token(s) preceding '{'; skipping
apparent function body c:\working\qommessage\qommessage\ammutils.h 14
Error 15 error C2146: syntax error : missing ';' before identifier
'errMsg' c:\working\qommessage\qommessage\ammutils.h 31
Error 16 error C4430: missing type specifier - int assumed. Note: C++
does not support
default-int c:\working\qommessage\qommessage\ammutils.h 31


#ifndef __AMM_UTILS__
#define __AMM_UTILS__

#include <string>
#include <ace/Synch.h>
#include <tibrv/tibrvcpp.h>

//namespace AMM
//{

class AMMException
{
public:
AMMException(int pErrCode = 0, string pErrMsg = "")
{
mErrCode = pErrCode;
mErrMsg = pErrMsg;
}
virtual ~AMMException()
{
}
AMMException(const AMMException& that)
{
mErrCode = that.mErrCode;
mErrMsg = that.mErrMsg;
}
int errCode() const
{
return mErrCode;
}
string errMsg() const
{
return mErrMsg;
}

private:
int mErrCode;
string mErrMsg;
};
..
..
..
#endif
 
M

mlimber

I cleaned all the object files and rebuilt again and this time i got
different errors. The following code is the fragement of the whole
AmmUtils.h file and can anyone be kind to tell me what's wrong with my
code?

Error 13 error C2062: type 'int'
unexpected c:\working\qommessage\qommessage\ammutils.h 14
Error 14 error C2334: unexpected token(s) preceding '{'; skipping
apparent function body c:\working\qommessage\qommessage\ammutils.h 14
Error 15 error C2146: syntax error : missing ';' before identifier
'errMsg' c:\working\qommessage\qommessage\ammutils.h 31
Error 16 error C4430: missing type specifier - int assumed. Note: C++
does not support
default-int c:\working\qommessage\qommessage\ammutils.h 31


#ifndef __AMM_UTILS__
#define __AMM_UTILS__

#include <string>
#include <ace/Synch.h>
#include <tibrv/tibrvcpp.h>

//namespace AMM
//{

class AMMException
{
public:
AMMException(int pErrCode = 0, string pErrMsg = "")
{
mErrCode = pErrCode;
mErrMsg = pErrMsg;
}
virtual ~AMMException()
{
}
AMMException(const AMMException& that)
{
mErrCode = that.mErrCode;
mErrMsg = that.mErrMsg;
}
int errCode() const
{
return mErrCode;
}
string errMsg() const
{
return mErrMsg;
}

private:
int mErrCode;
string mErrMsg;
};
.
.
.
#endif

Methinks you are probably lacking namespace qualification of
std::string (unless one of those other headers nastily puts a using
declaration in the header). Change each appearance of string to
std::string, or make a private alias, e.g.:

class A
{
typedef std::string string;
public:
A( const string& s );
};

Cheers! --M
 
L

Larry I Smith

Compiling a program using ACE + MSVC++8, got lots of errors and some
are listed as below:

Error 2 error C2894: templates cannot be declared to have 'C'
linkage c:\program files\microsoft visual studio
8\vc\include\iosfwd 39
Error 39 error C2733: second C linkage of overloaded function
'ACE_OS::atoi' not
allowed c:\tmp\ace+tao+ciao\ace_wrappers\ace\os_ns_stdlib.h 79
Error 41 error C2733: second C linkage of overloaded function
'ACE_OS::getenv' not
allowed c:\tmp\ace+tao+ciao\ace_wrappers\ace\os_ns_stdlib.h 116
..
..
When i changed #include <string> to #include <string.h> i got no errors
concerning iosfwd but the rest don't go away.
The config.h of ACE contains the following line:
#define ACE_HAS_STANDARD_CPP_LIBRARY 1
#include "ace/config-win32.h"
The version of ACE is Release,v 4.13 2005/08/05

It can be compiled on Linux/Unix and I suspect there is something wrong
with the installation of ACE. Does anyone has experienced the
same/similar problem before????

If the ACE headers are '*.h' instead of '*.hpp', you may have to
tell MSVC that they are C++ files (via the -Tp compiler switch if
I remember correctly). The error message seems to suggest that MSVC thinks
everything is 'C' instead of C++.

You might get more info help in an MSVC newsgroup.

Regards,
Larry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top