Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
As soon as you use the define way instead of typedef on pointer types, you will encounter interesting compiler messages once you declare several pointers at once and try to use them.
-
@arcsector Nah, that codebase is older than Stackoverflow so that the devs cannot have copy/pasted any bad answer from SO into their code.
-
I've always had the impression that #define is a bit of a poor solution in most cases. What's your opinion of when #define is used exactly correctly?
-
@AlgoRythm Whenever a purely textual replacement in awk/sed style is what you want. I use it mostly for expressions and conditional compiles.
Function like macros work also, but they have the issue of side effects in the arguments, and having a static inline function (sometimes even in a header file) is often a better alternative.
Related Rants
Today, I found this gem here in the codebase I've taken over:
#define BYTE unsigned char
FFS, use typedef, it's there for a reason. Solving the puzzle in the first comment.
rant
typedef
define
c