Skip to content

cannot use external const for array declaration #9

@mterber

Description

@mterber

Describe the bug
The following code

@[CConst (binding = "MAX_FROM_C", header = "strb.h")]
extern const MAX: nat8

@[EntryPoint]
activity Main () ()
    var arr: [MAX]nat8
    await true
end

leads to this compile error:

~/git/str-test$ blechc bug.blc 
error: The expression MAX must be a compile-time constant.
 --> bug.blc:6:15 [typing]

Means the external C constant cannot be used for declaring the array size in Blech.

Expected behaviour
I would expect that above approach works since MAX actually is a compile-time constant.

Or is this a deliberate restriction since Blech cannot verify that MAX is actually constant at compile time?

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    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