首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

error C4430: missing type specifier - int assumed. Note: C++ does not support de

2012-02-04 
error C4430: missing type specifier - int assumed. Note: C++ does not support default-intd:\court\c

error C4430: missing type specifier - int assumed. Note: C++ does not support default-intd:\court\courtcomm\courtcomm.cpp
以下代码在VS2005中编译出错,应该怎么修改?

C/C++ code
#include "stdafx.h"#include "CourtComm.h"#include <direct.h>#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif#define DllExport __declspec(dllexport)//extern    _ConnectionPtr    gpConnection;//extern    BOOL    gbIsConnectionOpen;extern    COURTINFO    gCourtInfo;extern char pwdCom[100];CString gStr;    char m_cIniFileName[300];//    char m_cPwd[20];    char m_cUid[20];    char m_cDatabase[100];    char m_cServer[100];    char m_cAppDir[257];//    Note!////        If this DLL is dynamically linked against the MFC//        DLLs, any functions exported from this DLL which//        call into MFC must have the AFX_MANAGE_STATE macro//        added at the very beginning of the function.////        For example:////        extern "C" BOOL PASCAL EXPORT ExportedFunction()//        {//            AFX_MANAGE_STATE(AfxGetStaticModuleState());//            // normal function body here//        }////        It is very important that this macro appear in each//        function, prior to any calls into MFC.  This means that//        it must appear as the first statement within the //        function, even before any object variable declarations//        as their constructors may generate calls into the MFC//        DLL.////        Please see MFC Technical Notes 33 and 58 for additional//        details.///////////////////////////////////////////////////////////////////////////////// CCourtCommAppBEGIN_MESSAGE_MAP(CCourtCommApp, CWinApp)    //{{AFX_MSG_MAP(CCourtCommApp)        // NOTE - the ClassWizard will add and remove mapping macros here.        //    DO NOT EDIT what you see in these blocks of generated code!    //}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CCourtCommApp constructionCCourtCommApp::CCourtCommApp(){    // TODO: add construction code here,    // Place all significant initialization in InitInstance}/////////////////////////////////////////////////////////////////////////////// The one and only CCourtCommApp objectCCourtCommApp theApp;BOOL CCourtCommApp::InitInstance() {    // TODO: Add your specialized code here and/or call the base class    BOOL bResult;    bResult = AfxOleInit();    if(bResult == FALSE)        return FALSE;    //oledb    if( _getcwd( m_cAppDir, _MAX_PATH ) == NULL )    {        AfxMessageBox("文件操作失败!");        return FALSE;    }    sprintf(m_cIniFileName,"%s\\%s",m_cAppDir,"CourtMis.ini");        //do 2.27    ::CoInitialize(NULL);//initialize surrounding for ado    //HRESULT hr;    //Modi 2.27    char cAppName[40]="DataServer";    char cKeyName[40]="Server";    char cDefault[40]="~!@#$%^&*()";    strcpy(m_cIniFileName, "CourtMis.ini");//    char ctmp[100];        GetPrivateProfileString(cAppName,cKeyName,cDefault,        m_cServer,100,m_cIniFileName);    strcpy(cKeyName,"Database");    GetPrivateProfileString(cAppName,cKeyName,cDefault,        m_cDatabase,100,m_cIniFileName);    strcpy(cKeyName,"Uid");    GetPrivateProfileString(cAppName,cKeyName,cDefault,        m_cUid,100,m_cIniFileName);        strcpy(cKeyName,"Pwd");    GetPrivateProfileString(cAppName,cKeyName,cDefault,        m_cPwd,100,m_cIniFileName);        strcpy(cKeyName,"ComPwd"); //读取通信密码    GetPrivateProfileString(cAppName,cKeyName,cDefault,        pwdCom,100,m_cIniFileName);    if(strcmp(m_cServer,cDefault)==0 ||        strcmp(m_cDatabase,cDefault) ==0 ||        strcmp(m_cUid,cDefault)==0 ||        strcmp(m_cPwd,cDefault)==0)    {        AfxMessageBox("配置文件未初始化或配置有误,请检查!",            MB_ICONERROR);        return FALSE;    }    //读取配置文件中的密码//////////////////////    CString str;    str.Format("driver={SQL SERVER};server=%s;database=%s;uid=%s;pwd=%s",        m_cServer,m_cDatabase,m_cUid,m_cPwd);    gStr = str;/*    try    {        if(gbIsConnectionOpen)        {            gpConnection->Close();            gbIsConnectionOpen=FALSE;        }        hr=gpConnection.CreateInstance(__uuidof(Connection));        if(FAILED(hr))            return FALSE;        hr=gpConnection->Open(_bstr_t(str),_bstr_t(L""),_bstr_t(L""),            adModeUnknown);        if(FAILED(hr))            return FALSE;        gbIsConnectionOpen=TRUE;    }    catch(...)    {        return FALSE;    }*/    //    return TRUE;    //First free the string allocated by MFC at CWinApp startup.    //The string is allocated before InitInstance is called.    free((void*)m_pszAppName);    //Change the name of the application file.    //The CWinApp destructor will free the memory.    m_pszAppName=_tcsdup(_T("通信处理"));        return CWinApp::InitInstance();}int CCourtCommApp::ExitInstance() {    // TODO: Add your specialized code here and/or call the base class    ::CoUninitialize();        return CWinApp::ExitInstance();}extern  "C" DllExport ComLocalVoucher(){    AFX_MANAGE_STATE(AfxGetStaticModuleState());    if(GetCourtInfo() != ERR_SUCCEED)        return FALSE;    pCommunicate(1);//main function for ado    return TRUE;}extern "C" DllExport ComDisInfo(){    AFX_MANAGE_STATE(AfxGetStaticModuleState());    if(GetCourtInfo() != ERR_SUCCEED)        return FALSE;    pCommunicate(2);//main function for ado    return TRUE;}extern "C" DllExport ComSendAll(){    AFX_MANAGE_STATE(AfxGetStaticModuleState());    if(GetCourtInfo() != ERR_SUCCEED)        return FALSE;    pCommunicate(3);//main function for ado    return TRUE;} 



[解决办法]
extern "C" DllExport ComLocalVoucher()
以及下面的几个函数都没有定义返回值类型。
改成extern "C" BOOL DllExport ComLocalVoucher()大概就可以了。
[解决办法]
#pragma warning(disable:4996);
最好是 #include <stdlib.h>

热点排行