|
|
| Do you know where your variables are? | |
| PerlMonks |
Re^2: External (extra) files when using Inline::CPPby afoken (Chancellor) |
| on Apr 19, 2024 at 07:51 UTC ( [id://11158969]=note: print w/replies, xml ) | Need Help?? |
|
You can always just #include "filename.c" from the inline C code. Most times, yes. But there are differences: If you use #include "filename.c", static functions and variables in filename.c suddenly become visible in the inline C code, whereas they are separate and not visible from inline C code if you just link with filename.o. That means you can't have one static type1 foo(...) in filename.c and another static type2 foo(...) in inline C code if you use #include "filename.c", but it works fine if you compile and filename.c to filename.o and just link with filename.o. Static variables are even worse. Two variables with equal name and type (one from inline C, one from filename.c) suddenly become one:
Note: no errors, no warnings.
No errors, no warnings when initialized in one file.
Both variables must be initialized to cause an error.
Alexander
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||