You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the IncludeFile() definition the built-in include headers (such as stdio.h) are protected against multiple inclusion, so the following code runs with no problems:
voidmain(void) {
while (1) {
#include<stdio.h>
}
}
I agree it does not make sense in itself, but read on to see why I need it. As per PicocPlatformScanFile() such a protection is not implemented for user-defined includes, so the following code will sooner or later explode in memory when interpreted by PicoC:
voidmain(void) {
while (1) {
#include"my-include.h"
}
}
with my-include.h containing arbitrary (but valid) C code, e. g.:
inti;
At the same time the same source compiled with gcc runs at constant memory. I would be grateful for explanation, what is the logic behind? What use case could take advantage of multiple inclusions of the same file?
For my usage scenario such a design is lethal, since I am trying to parametrize the program's behaviour by defining the body of a function in a separate file, which could be modified by the user, e. g.:
voidmy_func(void) {
#include"my-include.c"
}
The function itself would contain assignments and logical operations on input variables that modify output variables and would be called in a loop by the main program.
The text was updated successfully, but these errors were encountered:
According to the
IncludeFile()
definition the built-in include headers (such as stdio.h) are protected against multiple inclusion, so the following code runs with no problems:I agree it does not make sense in itself, but read on to see why I need it. As per
PicocPlatformScanFile()
such a protection is not implemented for user-defined includes, so the following code will sooner or later explode in memory when interpreted by PicoC:with
my-include.h
containing arbitrary (but valid) C code, e. g.:At the same time the same source compiled with gcc runs at constant memory. I would be grateful for explanation, what is the logic behind? What use case could take advantage of multiple inclusions of the same file?
For my usage scenario such a design is lethal, since I am trying to parametrize the program's behaviour by defining the body of a function in a separate file, which could be modified by the user, e. g.:
The function itself would contain assignments and logical operations on input variables that modify output variables and would be called in a loop by the main program.
The text was updated successfully, but these errors were encountered: