FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Function dependencies not respected with --disable-main · Issue #1727 · lcompilers/lpython · GitHub

Function dependencies not respected with --disable-main #1727

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL