4 ms·
The author says “I tried to define ‘main’ as an array of shorts with a modern compiler and it did not like that one bit”, but without saying which modern C comp
by robinhouston 6y ago
The author says “I tried to define ‘main’ as an array of shorts with a modern compiler and it did not like that one bit”, but without saying which modern C compiler or what it didn’t like about it.
This sort of trick should still be possible with modern compilers. GCC has the charming warning
warning: ‘main’ is usually a function [-Wmain]
if main is declared as something other than a function.
Here’s someone who got it to work in 2015, anyway: http://jroweboy.github.io/c/asm/2015/01/26/when-is-main-not-a-function.html http://jroweboy.github.io/c/asm/2015/01/26/when-is-main-not-...
- StavrosK 6y ago> I tried to define ‘main’ as an array of shorts with a modern compiler and it did not like that one bit He didn't even try to get it to work by changing that one bit!
- LainIwakura 6y agoAuthor of the article here. This was simply meant to be a minor observation, the focus of the article is not an investigation about the various ways to define main in your program. Anyway, this is the error I got if you're curious. (I left such things out because the article was getting long as is) warning: variable named 'main' with external linkage has undefined behavior [-Wmain] short main[] = { 16, 18 }; This is on OS X so it's clang 11.0.3.
- robinhouston 6y agoI’m sorry your comment has been downvoted. I can’t imagine why. Thanks for writing an interesting article. I realise this was a minor observation on your part, and I was remarking on it in that spirit. I’m sorry not to have made that clearer. I’ve found it rather dispiriting when writing of mine has been posted here, and the comments have seemed like nitpicking criticism, so I regret having given you that impression. One has to remind oneself that people who enjoy the article and have nothing to add will usually not leave comments, and so the comments give a misleading impression of how people felt about it. The message you quote above appears to be a warning, rather than an error.
- LainIwakura 6y agoNo harm no fowl, I appreciate constructive criticism but sometimes I'm on edge posting in these forums. It's like, this content is being posted to some of the best in the field - I want to be as precise and accurate as I can be. Anyway, I'm glad you found it interesting =)