• fubarx
    link
    fedilink
    arrow-up
    3
    ·
    6 months ago

    Haha. Thanks for checking. Given the C pre-processor, I’m sure there’s a way to maliciously bork it if someone sets their mind to it.

    • PM_ME_VINTAGE_30S [he/him]@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      6 months ago

      Well I just tried #define int void in C and C++ before a “hello world” program. C++ catches it because main() has to be an int, but C doesn’t care. I think it is because C just treats main() as an int by default; older books on C don’t even include the “int” part of “int main()” because it’s not strictly necessary.

      #define int void replaces all ints with type void, which is typically used to write functions with no return value.