• structuralize_this [none/use name]
    ·
    2 years ago

    The original code is c++, so g++ was the right call. The first couple errors are c++ like, as & isn't part of the type system in C. But it's valid c++. This is the correct error in C, for some new-ish version of gcc:

    main.c: In functionmain’:
    main.c:7:8: error: expected identifier or ‘(’ before ‘&’ token
         int& i = k;^
    main.c:9:5: error: ‘i’ undeclared (first use in this function)
     if (i == 17)
    

    This one is really interesting as it's the most basic bitch variable declaration, but it might get confused because int k probably isn't in the training lexicon.

    ref.c: In function ‘int main()’:
    ref.c:7:10: error: ISO C++ prohibits declaration of ‘k’ with no type [-fpermissive]
      int k = 17;