import_order_01.py:
from import_order_01b import f
@ccallback
def main1():
a: i32 = f()
print(a)
import_order_01b.py:
from lpython import i32
def f() -> i32:
return 42
Compile using:
$ lpython -I. --show-c --disable-main import_order_01.py
...
// Implementations
void main1()
{
int32_t a;
a = f();
printf("%d\n", a);
}
int32_t f()
{
int32_t _lpython_return_variable;
_lpython_return_variable = 42;
return _lpython_return_variable;
}
This then fails to compile due to:
$ clang x.c
x.c:41:9: error: implicit declaration of function 'f' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
a = f();
^
1 error generated.
The issue is that main1 depends on f, but f gets generated below the function. It only happens when --disable-main is used, but we need to use it.
import_order_01.py:
import_order_01b.py:
Compile using:
This then fails to compile due to:
The issue is that
main1depends onf, butfgets generated below the function. It only happens when--disable-mainis used, but we need to use it.