https://gustedt.wordpress.com/2024/01/16/white-space-does-matter-in-c23/ Skip to content Jens Gustedt's Blog White space does matter in C23 Usually in C identifiers are not directly followed by strings. But when U prefixed literals were introduced in C. there still were some rare clashes with existing code. This happened were a macro U that expanded to a string was used to add some sort of leading character sequence to a string. Prior, this usage was not sensible to whether or not there was a space between the two. By introducing the prefix the two usages (with and without space) became distinct and code changed its meaning or became invalid. So for this situation, space is in fact already significant. Generally, it is often assumed that in C spaces don't contribute much to the interpretation of programming text, but for C23 this has become an over-simplification that does not reflect the situation anymore. In addition to problems internal to C, there is a problem of interfacing with C++, where some of the rules are different. syntax meaning, C23 different meaning, C++ # define X function like macro, empty (A) # define X object macro, expands to (A) (A) 0x4'7'a hex number with digit separators 0x4 '7'a number, character literal, number, character literal and identifier with suffix 0x4 '7' a number, character literal, and identifier "%" PRIx64 valid format string for printf "%"PRIx64 valid format string for string literal with suffix printf R "(hor)" identifier followed by multi-byte string R"(hor)" identifier followed by raw multi-byte string, multi-byte string contains just hor R "hor" identifier followed by multi-byte string R"hor" identifier followed by invalid raw string multi-byte string U "hor" identifier, followed by multi-byte string U"hor" UTF-32 string It would be good if there could be some coordination here between C and C++ about such simple questions concerning lexing and the preprocessor. Any use of identifiers that are adjacent to character and string literals should be discouraged; I think that such constructs should just be excluded by the syntax. If we want this to be diagnosed it should be before compilation phase 4, in particular before macro expansion. Best would be if this is diagnosed in phase 3, lexing. Compilers and preprocessor implementations could start to warn about such possible collision immediately, as of today. I don't see much of a reason to still allow it. Even where there are valid uses, such as for the printf format string macros, the code becomes much easier to read if these are separated from the surrounding format string. Share this: * Share * * Email * Print * Facebook * Twitter * Related [1852c]Author Jens GustedtPosted on January 16, 2024January 16, 2024 Categories C23, preprocessor Post navigation Previous Previous post: The deprecated attribute in C23 does much more than marking obsolescence [1852c43e] Mastodon C as a language [dotd_newmeap_gustedt21-1] Copyright (c) 2010-2022 Jens Gustedt, Strasbourg, France P99 macros for C99 emulation of C11 Categories * C++ (10) * C11 (44) + defects (11) + feature request (2) + library (9) * C17 (10) * C2x (18) + C23 (11) * C99 (72) + integers (12) + language (33) + P99 (17) + preprocessor (13) + syntax (16) * compiler optimization (5) * core (3) * fediverse (1) * lock structures (8) * macros (1) * Modular C (5) * POSIX (13) + linux (2) * rants (5) * Uncategorized (1) Recent Posts * White space does matter in C23 * The deprecated attribute in C23 does much more than marking obsolescence * Early access to the C23 edition of Modern C * The fediverse is watching * The new __VA_OPT__ feature in C23 Top Posts & Pages * White space does matter in C23 * The deprecated attribute in C23 does much more than marking obsolescence * The new __VA_OPT__ feature in C23 * C23 implications for C libraries * Detect empty macro arguments * Early access to the C23 edition of Modern C * Modern C, Second Edition * Checked integer arithmetic in the prospect of C23 * Default arguments for C99 * Myth and reality about inline in C99 Search for: [ ] Search related * C99 * c threads * endif * preprocessor Follow Blog via Email Enter your email address to follow this blog and receive notifications of new posts by email. Email Address: [ ] Follow Join 193 other subscribers Meta * Register * Log in * Entries feed * Comments feed * WordPress.com Archives * January 2024 * December 2023 * October 2023 * August 2023 * June 2023 * December 2022 * January 2022 * October 2021 * January 2021 * December 2020 * November 2020 * June 2020 * May 2020 * March 2020 * September 2019 * August 2018 * June 2018 * April 2018 * August 2017 * May 2017 * March 2017 * January 2017 * November 2016 * September 2016 * August 2016 * July 2016 * July 2015 * May 2015 * April 2015 * February 2015 * October 2014 * September 2014 * April 2014 * December 2013 * October 2013 * August 2013 * July 2013 * February 2013 * December 2012 * November 2012 * October 2012 * August 2012 * July 2012 * May 2012 * April 2012 * March 2012 * February 2012 * January 2012 * December 2011 * November 2011 * October 2011 * July 2011 * June 2011 * March 2011 * February 2011 * January 2011 * December 2010 * November 2010 * October 2010 * September 2010 * August 2010 * July 2010 * June 2010 RSS RSS Feed RSS - Posts RSS Feed RSS - Comments Jens Gustedt's Blog Blog at WordPress.com. [Close and accept] Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use. To find out more, including how to control cookies, see here: Cookie Policy * Subscribe Subscribed + [wpcom-] Jens Gustedt's Blog Join 193 other subscribers [ ] Sign me up + Already have a WordPress.com account? Log in now. * + [wpcom-] Jens Gustedt's Blog + Customize + Subscribe Subscribed + Sign up + Log in + Copy shortlink + Report this content + View post in Reader + Manage subscriptions + Collapse this bar [b]