外部"C"和错误 C4430

extern "C" and error C4430

本文关键字:C4430 错误 外部      更新时间:2023-10-16

我在Visual Studio 2008下编译C++项目时遇到错误:

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

错误的行是:extern "C"
错误的行是以下头文件中的第 5 行:

#ifndef _BY_PORT_H
#define _BY_PORT_H
#ifdef __cplusplus
extern "C"
{
#endif
#if ( defined( WIN32 ) || defined(UNDER_CE) )
 #if !defined(WIN)
    #define WIN
 #endif
#endif
//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
//  Inclusion conditionnelle des headers systŠme
//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
#ifdef INCL_SYSTEM
#   define INCL_DOS
#   define INCL_WIN
#   define INCL_GPI
#endif
#if ( defined( INCL_DOS ) || defined( INCL_WIN ) || defined( INCL_GPI ) )
#   define SYSTEM_INCLUDED
    //ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
    //  Inclusion minimum dans Windows.h
    //ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
#   define WIN32_LEAN_AND_MEAN
#   define _INC_OLE_
#   define _OLE2_
#   define _WINCON_
#   define _WINVER_
#   define _WINNETWK_
#   define NORASTEROPS
#   define OEMRESOURCE
#   define NOKERNEL
#   define NOUSER
#   define NOMETAFILE
#   define NOMINMAX
#   define NOMSG
#   define NOOPENFILE
#   define NOSERVICE
#   define NOWH
#   define NOCOMM
#   define NOKANJI
#   define NOHELP
#   define NOPROFILER
#   if !defined(INCL_WIN)
#       define NODEFERWINDOWPOS
#   endif
#   ifdef INCL_WIN
#       undef NOUSER
#       undef NOMSG
#       undef NOOPENFILE
#       undef NOWH
#   endif
#   ifdef INCL_HELP
#       undef NOHELP
#   endif
#   ifdef INCL_GPI
#       undef NOMETAFILE
#       undef NORASTEROPS
#   endif
#   ifdef INCL_DOS
#       undef NOKERNEL
#   endif
#   if (defined(UNDER_CE))
#       undef NOUSER
#   endif
#   if defined(UNDER_CE)
#       define  min(a,b)    ((a)<(b))?(a):(b)
#       define  max(a,b)    ((a)>(b))?(a):(b)
#   endif
#   ifndef STRICT
#       define STRICT
#   endif
#   include <windows.h>
#   if ( defined(UNICODE) && !defined(UNDER_CE) )
#       undef UNICODE
#   endif
#   define ANSI_ONLY
#   include <commctrl.h>
typedef HDC HPS;
typedef HANDLE HAB;
#   ifndef RC_INVOKED
#       if ( defined(INCL_WIN) )
#           include <windowsx.h>
#       endif
#   endif
#else
#   define TRUE                        1
#   define FALSE                       0
    //ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
    //  D‚finition des types de donn‚es portables
    //ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
    typedef char                        CHAR;
    typedef char *                      PCHAR;
    typedef unsigned char               UCHAR;
    typedef unsigned char               BYTE;
    typedef short                       SHORT;
    typedef unsigned short              USHORT;
    typedef unsigned short              WORD;
    typedef long                        LONG;
    typedef unsigned long               ULONG;
    typedef unsigned long               DWORD;
    typedef int                         INT;
    typedef unsigned int                UINT;
    typedef void                        VOID;
    typedef char *                      PSZ;
    typedef int                         BOOL;
    typedef void *                      PVOID;
    typedef void *                      HANDLE;
#endif

// -----------------------    Defines communs   ------------------------------------
// -------------------------------------------------------------------------------------
#ifdef NULL
#undef NULL
#endif
#define NULL            0
#define CHSTDSEP        (char)1
#define SZSTDSEP        "1"
typedef char **         PPSZ;
typedef void **         PPVOID;
typedef long            Coord;
#   define LITTLE_ENDIAN    // I386
#if (defined(BYSTATICLIB) || defined (_LIB))
#   define DLLIMPORT                    extern
#   define DLLEXPORT                    
#else
#   define DLLIMPORT                    __declspec( dllimport )
#   define DLLEXPORT                    __declspec( dllexport )
#endif
#   define _APIFUNC                     __stdcall
#   define _APICFUNC                    __cdecl
#   define _CALLBFUNC                   __stdcall
#if defined(BYSTATICLIB)
#       define BY_LINK      
#else
#       define BY_LINK      DLLIMPORT
#endif
#define MAX_REGKEY_LENGHT 1024
#if defined (UNDER_CE)
#   include <4CE.hpp>
#endif
#ifdef __cplusplus
}
#endif
#endif  // _BY_PORT_H

我已经用谷歌搜索了一段时间,但我还没有找到为什么出现 C4430 错误。
有谁知道为什么?

您问题中的代码编译良好。可以在包含它的源文件中找到该问题。该文件将包含#include "..."语句,该语句在问题中包含头文件,在不适合编写extern "C"的位置。