Find the error I spend 3 hours on!!!

Come on!!!

  • 19
    *laughs in null*
  • 9
    Shouldn't the compiler show a warning (Wparentheses)?
  • 8
    All your data is NULL.

    Stuff like this makes me appreciate modern IDEs.
  • 2
    @sbiewald It has, I couldnt see it

    @Demolishun my VSCode isnt configured properly, so it sometimes doesnt show the error
  • 14
    That's why you ALWAYS compile with -Wall -Wextra -Werror. You paid this lesson with 3 hours of your life, now learn it.

    And with -Werror, compilation would have failed so that you would have known something was odd with the code.
  • 1
    @Fast-Nop how do I set that in CMake?
  • 6
    Modify the cmake flags env var
  • 1
    (but I'm biased due to seeing your snippet)
  • 3
    @frogstair I don't use Cmake, but in Make, it goes in the CC-flags. And it's for GCC (I think also Clang) - if you're using MSCL, check its documentation.

    You may also want to have a look at CppCheck. Super easy to use, nice GUI, Windows version available.
  • 7
    *laughs in Haskell* *half the room doesn't even recognize this as a laugh*
  • 2

    add_compile_options(-Wall -Wextra -pedantic -Werror)

    (see https://cmake.org/cmake/help/... )

    or even better https://stackoverflow.com/questions...
  • 5
    First off: cmake sucks ass. Makefiles for the win.

    @Fast-Nop amen!
  • 0
  • 0
    @nitwhiz doesn't cmake just make a makefile for you to save the hassle?
  • 1
    If you had used C++, you could have gotten the same error, but with templates.
  • 2
    @frogstair dunno, to me cmake looks like a config file with bullshit syntax used to form make commands.

    Makefiles on the other hand are just typed out commands, no fucken syntax to learn here. At least not much.
  • 0
    @nitwhiz Indeed. CMake developers could have made any language they wished, to describe a platform-agnostic configuration and build process.

    They made CMake.
  • 0
    @nitwhiz idk, a 10 line cmake file with clearly layed out commands generates a 50 line makefile in which I don't understand a single line
  • 0
    @frogstair Sure. But it will also generate a visual studio solution (if you want to), works with all compilers and linkers (and looks up the compiler specific arguments if required), finds libraries and headers. The output isn't supposed to be human readable.
    When "just" compiling for a single target, cmake is usually irrelevant. When compiling a complex project, supporting a variety of platforms, it does a lot of work for you.
  • 0
    sometimes one might wish C was more like JS and required tripple-equal comparisons... just to be sure :)
  • 0
    Shouldn't that be a ==
  • 0
    @netikras or less like js and didn't let you put anything that isn't a boolean inside an if statement's condition
  • 2
    @CptFox I'm going to create a Laugh monad transfomer that randomly outputs ""HAHAHA" between execution of lifted functions
Add Comment