Skip to content

[BUG] - Transpile fails to emit global variables #173

Description

@glm11-aoc

Describe the bug
The -transpile flag does not transfer over global variables

To Reproduce
Steps to reproduce the behavior:

  1. Run hcc -transpile file.hc | gcc -x c -
  2. Receive error pertaining to missing global

Example Program

U64 *memo;

U64 Fib(U64 n){
    if(n < 2){
        return 1;
    }
    if (memo[n] != 0){
        return memo[n];
    }
    memo[n] = Fib(n-1) + Fib(n-2);
    return memo[n];
}


U0 Main(I32 argc, U8 **argv){
    memo = MAlloc(sizeof(U64)*101);
    "%llu\n",Fib(100);
    Free(memo);
}

Expected behavior
Globals should be present in the transpiled C code.

Compiler version
hcc beta-v0.0.9
binary: /usr/local/hcc
commit-hash: fd2d410
arch: Linux x86_64
build: Release

Desktop (please complete the following information):

  • OS:Ubuntu 24.04

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions