Nice to ask questions for the first time. Thank you in advance.

I have a C ++ grammar and ask questions.

An error occurs when declaring the function

testcpp in the header file.
I don't understand grammatical errors and I'm in trouble.
As described in "What I tried", moving the declaration to the cpp file works fine, but I do not know how to fix it.

What I want to realize is a C language program that wants to call a function created in C ++.
Would you give me wisdom? Thank you in advance.

Error message
Checking project dependencies ...
Building ZDLL.cbproj (Debug, Win32)
bcc32 "zdll_File1.c" command line
[bcc32 error] zdll_Unit1.h (5): E2040 declaration is not properly terminated
  Detailed analysis information
    zdll_File1.c (23): #include zdll_Unit1.h
Elapsed time: 00: 00: 00.2
Applicable source code
// zdll_Unit1.cpp
#pragma hdrstop
#pragma package (smart_init)
#include "zdll_Unit1.h"
extern "C" __declspec (dllexport) int testcpp (int i)
  return i;
#ifndef zdll_Unit1H
#define zdll_Unit1H
extern "C" __declspec (dllexport) int testcpp (int);

in zdll_Unit1.h,

extern "C" __declspec (dllexport) int testcpp (int);


is moved to zdll_Unit1.cpp, compilation will be completed correctly.
Other than that, the order of declaration of #include zdll_Unit1H was moved up or down, but it was not possible.

Supplemental information (FW/tool version etc.)

RAD Studio 10.3 Academic version
Windows10 Professional

  • Answer # 1

    The cause was not identified, but may it be accidental?
    I think it's like that now.

    I will refer to the advice I received. Thank you very much.

  • Answer # 2

    Self-solved. Do you have any questions?

    [What I did]
    I started the project again from a clean state.
    Add C ++ units (cpp and h files) to the project
    , Rename each

    Copy and paste the code from the question.

    The compilation finished successfully.
    I'm glad that I was able to do it normally, but this time I can't reproduce the error when I asked. .
    -Change the file name, rewrite the declaration and repeat the compilation several times.

    I didn't know the reason and it was a complete solution.


    Can you give me advice?