2011-04-28 68 views
0

如何在這個頭文件中正確聲明這個函數?在頭文件中聲明一個CString函數

CString ExecuteExternalProgram(CString pictureName);

#pragma warning(disable: 4049) /* more than 64k source lines */ 
#ifndef __REQUIRED_RPCNDR_H_VERSION__ 
#define __REQUIRED_RPCNDR_H_VERSION__ 475 
#endif 

#include "rpc.h" 
#include "rpcndr.h" 

CString ExecuteExternalProgram(CString pictureName); //<---- THIS LINE IS ERROR? 

#ifndef __RPCNDR_H_VERSION__ 
#error this stub requires an updated version of <rpcndr.h> 
#endif // __RPCNDR_H_VERSION__ 


#ifndef __Example1_h__ 
#define __Example1_h__ 

#if defined(_MSC_VER) && (_MSC_VER >= 1020) 
#pragma once 
#endif 

/* Forward Declarations */ 

#ifdef __cplusplus 
extern "C"{ 
#endif 


#ifndef __Example1_INTERFACE_DEFINED__ 
#define __Example1_INTERFACE_DEFINED__ 

void Output( 
    /* [string][in] */ const char *szOutput); 


extern handle_t hExample1Binding; 


extern RPC_IF_HANDLE Example1_v1_0_c_ifspec; 
extern RPC_IF_HANDLE Example1_v1_0_s_ifspec; 
#endif /* __Example1_INTERFACE_DEFINED__ */ 


#ifdef __cplusplus 
} 
#endif 

#endif 

回答

1

我創造了在Visual Studio中的空項目,我沒有任何問題,編譯:

#include <atlstr.h> 

#include "Example1.h" // Direct copy of your code from above 

int main(int argc, char **argv) { 
    return 0; 
} 

我是從http://www.codeguru.com/forum/showthread.php?t=231164通風報信有關atlstr.h。

這就是你所說的「恰當地」聲明的意思嗎?

+0

這是因爲我在頭文件中聲明CString時出錯。是因爲unicode嗎? – karikari 2011-05-20 00:27:00

+1

我真的認爲你看到的錯誤是因爲CString在使用之前沒有聲明。如果您將 '#包括' 添加到您的頭文件的頂部,我不認爲您會看到任何錯誤。 – Mat 2011-05-31 17:24:24