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 functiontestcpp 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.
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
Failure
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;
}
//zdll_Unit1.h
#ifndef zdll_Unit1H
#define zdll_Unit1H
extern "C" __declspec (dllexport) int testcpp (int);
#endif
in zdll_Unit1.h,
extern "C" __declspec (dllexport) int testcpp (int);
Ifis 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.
RAD Studio 10.3 Academic version
Windows10 Professional
-
Answer # 1
-
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
.Unit1.cpp->zdll_Unit1.cpp
.Unit1.h->zdll_Unit1.h
, Rename eachCopy 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?
Please.
Related articles
- c ++ - i want to know how to solve the error "undefined xref"
- c ++ - forward declaration compilation error for c structs
- c ++ - c language: please tell me how to deal with the error message "bus error"!
- c ++ - error: expected unqualified-id before ‘this’
- c ++: error in search&display program in data file
- i get an error with c ++ opencv
- php - i want to solve the problem that an error occurs as soon as i put $result = $stmt-> fetch (pdo :: fetch_assoc) ;
- please tell me how to solve the error that occurs in css
- i want to solve an error on the ruby on rails ec site nomethoderror in cartscontroller # add_item
- about the error when linking multiple c ++ files with makefile
- c ++ - error in loaddivgraph function
- c ++ - i get an error when i try to compile opencv
- python - please tell me how to solve the value error that occurred when converting csv file data to numpy array
- html - i'm getting an error because its mime type ~, but i don't know how to solve it
- i want to solve the ssl error "dh key too small in" that appears when using the national diet library api with php
- c ++ - i get a syntax error
- c ++ - could you please tell me how to resolve the error when using "wiring pih" and "bcm2835h" of raspberry
- vscode c ++ cmake "error: no available generator found"
- i want to solve the error that was spit out in [django]
- javascript - i want to solve cors error by using credential (cookie)
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.