2 ms·
There are plenty of systems where errno is #define'd to a more complex expression in order to provide per-thread errors. From glibc's bits/errno.h on Linux:
by koenigdavidmj 12y ago
There are plenty of systems where errno is #define'd to a more complex expression in order to provide per-thread errors. From glibc's bits/errno.h on Linux:
# ifndef __ASSEMBLER__
/* Function to get address of global `errno' variable. */
extern int *__errno_location (void) __THROW __attribute__ ((__const__));
# if !defined _LIBC || defined _LIBC_REENTRANT
/* When using threads, errno is a per-thread value. */
# define errno (*__errno_location ())
# endif
# endif /* !__ASSEMBLER__ */
#endif /* _ERRNO_H */
I wouldn't expect it to be common to see a macro with parameters being an lvalue, though. It wouldn't phase a C++ programmer, since references make it possible and even idiomatic to return lvalues. Where you normally see this is:
x["foo"] = "bar";
is just syntactic sugar for
// operator[] could be any "normal" function name!
x.operator[]("foo") = "bar";