#define, #macro, #error refuse to function - basic

I genuinely don't understand what's wrong with my code.
#ERROR "Code not finished!"
This claims a syntax error, despite literally being in the manual.
I am expecting it to return "Error: Code not finished!" instead of "Error: syntax error".
There is no reason for this to not function. This also happens with any command directed at the compiler, such as #macro and #define. Again, taken directly from the manual.
What could I possibly be doing wrong?

It turns out I didn't enable the preprocessor. I feel so dumb.

Related

I cannot start any program from PythonStdioGames and get an error, how can I prevent this?

I am relatively new to Python and programming in general and currently learning Python with the book "Automate the boring stuff with Python" by Al Sweigart. As recommended in the book, I wanted to do some programming exercises myself by looking into the module gamesbyexample (https://github.com/asweigart/pythonstdiogames/).
However, whenever I start one of the games I get the following error message in the Terminal:
AdminisatorsMBP:~ simon$ /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 /Users/simon/Library/Python/3.8/lib/python/site-packages/gamesbyexample/__crashdetector__.py 0.1.5 /Users/simon/Library/Python/3.8/lib/python/site-packages/gamesbyexample/alphabetizequiz.py
File "/Users/simon/Library/Python/3.8/lib/python/site-packages/gamesbyexample/__crashdetector__.py", line 16
except KeyboardInterrupt, EOFError:
^
SyntaxError: invalid syntax
I tried using multiple versions of python, 3.7.7 and 3.8.2, but with both versions, the same message comes up.
How could I get this running properly?
This is a syntax error, which means that you're probably missing something in the code that the compiler was expecting to be there.
If you could please also post the code, we could see what the problem is.

PyCharm type hint warning in `print()` function when passing in a file

The screenshot above is pretty self-explanatory. PyCharm throws a warning, but as far as I understand, the code above is a legitimate way of using the print() function, isn't it?

Recordwildcards crashes at runtime in yesod app

I ran into the following error which is quite surprising. I added a field to the AppSettings in a Yesod app (using the Yesod scaffholding) and to my surprise, everything compiled even though I didn't do anything else (I was expecting to have to add somewhere a default value to the construction of AppSettings, but not). I got a runtime error instead telling me that a field was missing.
It appears that the only construction to AppSetting uses the RecordWildCards extension and looks like AppSettings{..}. Not defining the new field didn't generate an error but a warning (I didn't see it, because I was running test in continuous mode using stack test --file-watch). How is that possible ?
I try to reproduce the problem in a simple file and I get an error not a warning. So why do I get a warning for Yesod ? Is it a compilation flag or something ?
Edit
This is not specific to Yesod. I've made the test again with a simple file and it generates a warning not an error.
According to changelog in GHC, "that not a bug, it's a feature": https://ghc.haskell.org/trac/ghc/ticket/5334
You can change this behavior by changing type of your fields to strict (prepend a ! to type name - like !Int) - however, then you lose laziness (more about effects of strict types: Advantages of strict fields in data types)
Of course, you can also make it an error by slamming in -Werror compilation option, but then you need to be very strict about your code (no unused imports, no unused variables, even when unpacking a record etc.), or get rid of -Wall and turn on only warnings you perceive as important.

Make GHCi load a source file in any state, and just throw errors at runtime [duplicate]

I swear I saw a new feature in a recent set of GHC release notes - but now I can find no reference to it. Am I delusional, or does this feature actually exist?
It was to do with loading incomplete modules. As best as I can remember, it allows you to turn off compilation errors due to undefined variables. (Naturally, at run-time this causes an exception to be thrown if you try to actually use the undefined variables for anything.) Does that sound familiar? Or is my mind making this up?
You are looking for a compile time option, vs a language extension, of "defer errors to runtime". That is, compile with -fdefer-type-errors.

C++/CLI typedef cliext LNK2022 error

If you write a C++/CLI application, and you attempt to use STL:CLR via cliext and you typedef for example a cliext map then you will find that it doesn't work due to a LNK2022 error.
I was mistaken in my original answer on how to mitigate the link error as pointed out by Hans in the comment above. Though, he does recommend using Dictionary instead, it is still possible to continue using cliext and solve the problem without unusual workarounds.
The actual answer is that templates do not allow external linkage. This means that somewhere I was using the cliext::map outside of my namespace. The moment that was eliminated, the link error goes away.

Resources