Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old April 4th, 2006, 09:05 AM
martinbriefcase@hotmail.com
Guest
 
Posts: n/a
Default C linkage problem with ACE on windows

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????

  #2  
Old April 4th, 2006, 11:05 AM
martinbriefcase@hotmail.com
Guest
 
Posts: n/a
Default Re: C linkage problem with ACE on windows

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

  #3  
Old April 4th, 2006, 01:55 PM
mlimber
Guest
 
Posts: n/a
Default Re: C linkage problem with ACE on windows

martinbriefcase@hotmail.com wrote:[color=blue]
> 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[/color]

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

  #4  
Old April 5th, 2006, 12:15 AM
Larry I Smith
Guest
 
Posts: n/a
Default Re: C linkage problem with ACE on windows

martinbriefcase@hotmail.com wrote:[color=blue]
> 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????
>[/color]

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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,338 network members.