我下载了一个ACE之后安装好了。也把那一些DLL编译好了。
之后我就看文档。
把那个第一个例子的代码帖到一个控制台方式的工程里。
一编译,就出了很多的错误。
103个
c:\downloads\ace-5.4\ace_wrappers\ace\ace_wchar.h(168) : error C2143: syntax error : missing ')' before ';'
有一些东西没有定义。
我运行那一些在目录下的例子代码都没有什么问题。
就是自已新建的这样的代码就出问题了。请高手指点一下。

解决方案 »

  1.   

    代码就是帮助文件里的第二章的例子:
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    //// This example is from the ACE Programmers Guide. 
    ////  Chapter: "IPC SAP" (Interprocess Communication Mechanisms in ACE). 
    //// For details please see the guide at 
    //// http://www.cs.wustl.edu/~schmidt/ACE.html 
    ////  AUTHOR: Umar Syyid ([email protected]
    //// and Ambreen Ilyas ([email protected]
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    //Example 1 
    #include "ace/SOCK_Acceptor.h" 
    #include "ace/SOCK_Stream.h" 
    #define SIZE_DATA 18 
    #define SIZE_BUF 1024 class Server{ 

    public: 
    Server (int port): 
      server_addr_(port),peer_acceptor_(server_addr_){ 
      data_buf_= new char[SIZE_BUF]; 
      } 
      
      //Handle the connection once it has been established. 
      //Here the connection is handled by reading SIZE_DATA amount of data 
      //from the remote and then closing the connection 
      //stream down. 
      int handle_connection(){ 
      // Read data from client 
      if(new_stream_.recv_n (data_buf_, SIZE_DATA, 0)==-1) 
      ACE_ERROR ((LM_ERROR, "%p\n", "Error in recv")); 
      
      
      ACE_DEBUG((LM_DEBUG,"Server recieved %s \n",data_buf_)); 
      
      // Close new endpoint 
      if (new_stream_.close () == -1) 
      ACE_ERROR ((LM_ERROR, "%p\n", "close")); 
      return 0; 
      } 
      //Use the acceptor component peer_acceptor_ to accept the connection 
      //into the underlying stream new_stream_. After the connection has been 
      //established call the handle_connenction() method. 
      int accept_connections (){ 
      if (peer_acceptor_.get_local_addr (server_addr_) == -1) 
      ACE_ERROR_RETURN ((LM_ERROR,"%p\n","Error in get_local_addr"),1); 
      
      ACE_DEBUG ((LM_DEBUG,"Starting server at port %d\n", 
      server_addr_.get_port_number ())); 
      
      
      // Performs the iterative server activities. 
      while(1){ 
      ACE_Time_Value timeout (ACE_DEFAULT_TIMEOUT); 
      if (peer_acceptor_.accept 
      (new_stream_, &client_addr_, &timeout)== -1){ 
      ACE_ERROR ((LM_ERROR, "%p\n", "accept")); 
      continue; 
      } 
      else 
      ACE_DEBUG((LM_DEBUG, 
      "Connection established with remote %s:%d\n", 
      client_addr_.get_host_name(),client_addr_.get_port_number())); 
      //Handle the connection 
      handle_connection(); 
      } 
      } 
      
      
      
    private: 
    char *data_buf_; 
    ACE_INET_Addr server_addr_; 
    ACE_INET_Addr client_addr_; 
    ACE_SOCK_Acceptor peer_acceptor_; 
    ACE_SOCK_Stream new_stream_; 
    ACE_HANDLE newhandle; 
    }; int main (int argc, char *argv[]){ 
    if(argc<2){ 
    ACE_ERROR((LM_ERROR,"Usage egX <port_num>")); 
    ACE_OS::exit(1); 

    Server server(ACE_OS::atoi(argv[1])); 
    server.accept_connections(); 
    } #include "ace/IOStream.h"
    #include "ace/SOCK_Stream.h"
    #include "ace/Svc_Handler.h"#define SIZE_DATA 18 
    #define SIZE_BUF 1024 int main (int argc, char *argv[]){ 
    if(argc<2){ 
    ACE_ERROR((LM_ERROR,"Usage egX <port_num>")); 
    ACE_OS::exit(1); 

    Server server(ACE_OS::atoi(argv[1])); 
    server.accept_connections(); 

      

  2.   

    你这个情况要这样处理才会可以使用的.1.要去到主页上下载一个最新的版本.2.把那个函数库里的ACE对应的那一些DLL都要编译出来.3.留意一下在你自己的工程里的使用的lib文件的版本.如果你是在debug下做程序.一定要使用debug版本的lib文件.我就是这样做的,就能使用ACE库了.