Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CCPP]: Generic Type is not resolved in header for target CCPP #2195

Open
mkhubaibumer opened this issue Feb 14, 2024 · 2 comments
Open

[CCPP]: Generic Type is not resolved in header for target CCPP #2195

mkhubaibumer opened this issue Feb 14, 2024 · 2 comments
Labels
bug Something isn't working c Related to C target

Comments

@mkhubaibumer
Copy link
Collaborator

We implemented Generics in such a way that Template type is defined with its concrete type in source file and it gets replaced with the concrete type in header file
For target CCPP source file resolution is working as expected but the template type doesn't get resolved in header file causing the state variable declaration to fail the compilation

Consider the following code

target CCPP;

preamble {=
    #include <iostream>
    #include <memory>
=}

reactor Base<T1> {
    input in:T1
    reaction(in) {=
        printf("Hello\n");
    =}
}

reactor Der<T1> extends Base {
    state val:std::vector<T1>
    reaction(in) {=
        self->val.push_back(in->value);
        printf("well\n");
    =}
    input print:bool
    reaction(print) {=
        printf("values: [ ");
        for(const auto &it : self->val) {
            printf("%d ", it);
        }
        printf("]\n");
        self->val.clear();
    =}
}

reactor T {
    timer t(0, 2sec)
    output out:int
    reaction(t) -> out {=
        lf_set(out, rand());
    =}

    timer t1(0, 1min)
    output print:bool
    reaction(t1) -> print {=
        lf_set(print, true);
    =}
}

main reactor {
    t= new T();
    d= new Der<int>();
    t.out -> d.in
    t.print -> d.print
}

state val:std::vector<T1> fails compilation due to the above mentioned issue

@mkhubaibumer mkhubaibumer added bug Something isn't working c Related to C target labels Feb 14, 2024
@cmnrd
Copy link
Collaborator

cmnrd commented Feb 22, 2024

@petervdonovan do you think this would be easily fixable?

@petervdonovan
Copy link
Collaborator

@petervdonovan do you think this would be easily fixable?

Probably.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working c Related to C target
Projects
None yet
Development

No branches or pull requests

3 participants