Giter VIP home page Giter VIP logo

Comments (2)

Chasmiccoder avatar Chasmiccoder commented on September 27, 2024

How do I reproduce this bug?

The simc code:
MAIN

print( "Hello World\n" )
var a = 13
var *ptr = &a

print( "Var 'a' is: \n" )
print( a )
print( "\n" )

print( "Pointer to 'a' is: \n" )
print( ptr )
print( "\n" )

print( "Value of pointer to 'a' is: \n" )
print( *ptr )
print( "\n" )

END_MAIN

We get this C code:
#include <stdio.h>

int main() {

printf("Hello World\n");
int a = 13;
float *ptr =  & a;

printf("Var 'a' is: \n");
printf("%d", a);
printf("%c", '\n');

printf("Pointer to 'a' is: \n");
printf("%d", ptr);
printf("%c", '\n');

printf("Value of pointer to 'a' is: \n");
printf("%d",  * ptr);
printf("%c", '\n');
return 0;

}

This code seems okay to me.

from sim-c.

Chasmiccoder avatar Chasmiccoder commented on September 27, 2024

Actually, on a side note, Sim-C is dynamically typed, so this should apply to pointers as well, right?

For this simc code:
MAIN

print( "Hello World\n" )
var a = 13
var *ptr = &a

print( "Value of pointer to 'a' is: \n" )
print( *ptr )
print( "\n" )

var b = 3.14

ptr = &b

print( "Pointer to 'b' is: \n" )
print( ptr )
print( "\n" )

print( "Value of pointer to 'b' is: \n" )
print( *ptr )
print( "\n" )

END_MAIN

We get this C code:
#include <stdio.h>

int main() {

printf("Hello World\n");
int a = 13;
float *ptr =  & a;

printf("Value of pointer to 'a' is: \n");
printf("%d",  * ptr);
printf("%c", '\n');

float b = 3.14;
ptr =  & b;
printf("Pointer to 'b' is: \n");
printf("%f", ptr);
printf("%c", '\n');

printf("Value of pointer to 'b' is: \n");
printf("%f",  * ptr);
printf("%c", '\n');

return 0;

}

This C code gives us the following error:
image

I think this simc code should produce a valid C code, but I'm not too sure.
Hope this made sense.

from sim-c.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.