C2732 - Communication specification error

I am using VS2008. I get the following error.

BUILD: [02:0000000295:ERRORE] c:\wince700\platform\am33x_bsp\src\bootloader\bootpart\bootpart_e.cpp(61) : error C2732: linkage specification contradicts earlier specification for 'SdhcInitialize' {log="C:\WINCE700\platform\AM33X_BSP\SRC\BOOTLOADER\bldsys.log(103)"}
BUILD: [02:0000000297:ERRORE] NMAKE : fatal error U1077: 'C:\WINCE700\sdk\bin\i386\ARM\cl.EXE' : return code '0x2' {log="C:\WINCE700\platform\AM33X_BSP\SRC\BOOTLOADER\bldsys.log(104)"}
BUILD: [02:0000000299:ERRORE]  clean TargetCompilePass  -nologo BUILDMSG=Stop.  BUILDROOT=C:\WINCE700\platform\AM33X_BSP CLEANBUILD=1 NOLINK=1 NOPASS0=1 failed - rc = 2. {log="C:\WINCE700\platform\AM33X_BSP\SRC\BOOTLOADER\bldsys.log(105)"}

file_1.cpp

extern "C"
{
   // some extern declarations
   extern void SdhcInitialize(DWORD slot);
}

file_2.c

void SdhcInitialize(DWORD slot)
{
//some code
}

Please help me decide.

+4
source share
3 answers

I assume that you have a heading that contains the prototype for the function SdhcInitialize()and that the heading was written for use by C programs. So, for example, the heading file might contain something like the following line:

SD_API_STATUS SdhcInitialize(DWORD slot);

without being enclosed in a block extern "C" {}(since the header is for C programs).

In addition, I suspect that this title is being included - directly or indirectly - on file_1.cpp

, ++ - , ++ , SdhcInitialize() ++.

:

  • , :

      #if __cplusplus
      extern "C" {
      #endif
    
      // declarations go here
    
      #if __cplusplus
      }
      #endif
    

    , ++ , extern "C", C extern "C" ( C).

    , , C - , C ++ .

  • - , , ++, :

      extern "C" {
      #include "Sdhc-header.h"
      }
    
+6

extern "C" { ... }, extern .

extern "C"
{
   // some extern declarations
   SD_API_STATUS SdhcInitialize(DWORD slot);
}
+1

When you try to include “some header files of the C file” in the “C ++ file” (there are some in the header file where extern "C"for some functions).

include the header before, solve the problem.

eg. Try moving #include "myHeader.h"to the top lines of your C ++ file.

This solves my problems.

Hope this helps ....

0
source

All Articles