Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7503

SDK • How to deal with 2 source files in one project?

$
0
0
I have a tiny little project consisting of two C files:
1 - RDSgeneratorDualCoreV01.c (containing main) and
2 - core1. c (containing several functions)
Both located in the same project directory.
Settings:
In the "main" programe,

Code:

#include "core1.c"  // last include
and in
CMakeList.txt

Code:

add_executable(RDSgeneratorDualCoreV01 RDSgeneratorDualCoreV01.c core1.c)
Compile Result
[build] E:/Documents/1a_VSCode/RDSgeneratorDualCoreV01/core1.c:125:5: error: implicit declaration of function “gpio_put” [-Wimplicit-function-declaration]
[build] 125 | gpio_put(4, 1) ;
[build] | ^~~~~~~~
It looks like some includes are missing that are already included in the main programme.
The literature states that each include is treated as a new file by the compiler and does not share any definitions with the including file.
OK, so far so good, no problem, let's add stdio.h:
Result (for almost all variables or functions defined in core1.c):
Multiple definition of ‘sig1’; CMakeFiles/RDSgeneratorDualCoreV01.dir/RDSgeneratorDualCoreV01.c.obj:E:/Documents/1a_VSCode/RDSgeneratorDualCoreV01/core1.c:50: defined here first ....
It seems to me that core1.c is somehow included twice.

How can this be corrected?

Greetings,
Martin

Statistics: Posted by MartinHill — Tue Feb 17, 2026 7:51 pm — Replies 4 — Views 68



Viewing all articles
Browse latest Browse all 7503

Trending Articles