Title: token pasting with "defined" works with gcc (cpp) but not simplecpp · Issue #218 · cppcheck-opensource/simplecpp · GitHub
Open Graph Title: token pasting with "defined" works with gcc (cpp) but not simplecpp · Issue #218 · cppcheck-opensource/simplecpp
X Title: token pasting with "defined" works with gcc (cpp) but not simplecpp · Issue #218 · cppcheck-opensource/simplecpp
Description: Adding this issue originally posted to the cppcheck forum per @danmar 's request. I am using a third-party peripheral library from the manufacturer of the microprocessor that we are using, and it contains a token-pasting macro identical ...
Open Graph Description: Adding this issue originally posted to the cppcheck forum per @danmar 's request. I am using a third-party peripheral library from the manufacturer of the microprocessor that we are using, and it c...
X Description: Adding this issue originally posted to the cppcheck forum per @danmar 's request. I am using a third-party peripheral library from the manufacturer of the microprocessor that we are using, and ...
Opengraph URL: https://github.com/cppcheck-opensource/simplecpp/issues/218
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"token pasting with \"defined\" works with gcc (cpp) but not simplecpp","articleBody":"Adding this issue originally posted to the [cppcheck forum](https://sourceforge.net/p/cppcheck/discussion/development/thread/9f44f31915/) per @danmar 's request.\r\n\r\nI am using a third-party peripheral library from the manufacturer of the microprocessor that we are using, and it contains a token-pasting macro identical to the one labeled \"THIS ONE\" below:\r\n```\r\n#define __FOO__ 1\r\n \r\n#define IS_DEFINED(name) (defined(__ ## name ## __)) // \u003c--THIS ONE\r\n\r\n#warning Before IS_DEFINED(FOO)\r\n\r\n#if IS_DEFINED(FOO)\r\n#warning Inside IS_DEFINED(FOO)\r\n#endif\r\n\r\n#warning After IS_DEFINED(FOO)\r\n```\r\nWhen I run cpp (Ubuntu v9.3.0) the `IS_DEFINED()` macro works as intended:\r\n```\r\n$ cpp ./test_token_pasting.cpp \r\n# 1 \"./test_token_pasting.cpp\"\r\n# 1 \"\u003cbuilt-in>\"\r\n# 1 \"\u003ccommand-line>\"\r\n# 1 \"/usr/include/stdc-predef.h\" 1 3 4\r\n# 1 \"\u003ccommand-line>\" 2\r\n# 1 \"./test_token_pasting.cpp\"\r\n./test_token_pasting.cpp:5:2: warning: #warning Before IS_DEFINED(FOO) [-Wcpp]\r\n 5 | #warning Before IS_DEFINED(FOO)\r\n | ^~~~~~~\r\n./test_token_pasting.cpp:8:2: warning: #warning Inside IS_DEFINED(FOO) [-Wcpp]\r\n 8 | #warning Inside IS_DEFINED(FOO)\r\n | ^~~~~~~\r\n./test_token_pasting.cpp:11:2: warning: #warning After IS_DEFINED(FOO) [-Wcpp]\r\n 11 | #warning After IS_DEFINED(FOO)\r\n | ^~~~~~~\r\n```\r\nHowever when I run simplecpp:\r\n```\r\n$ ./simplecpp test_token_pasting.cpp\r\n\r\ntest_token_pasting.cpp:5: #warning: #warning Before IS_DEFINED(FOO)\r\ntest_token_pasting.cpp:11: #warning: #warning After IS_DEFINED(FOO)\r\n```\r\n...the `IS_DEFINED()` macro doesn't appear to work. Per @danmar, the specs say this macro results in undefined behavior, but it does seem to work with this version of gcc.","author":{"url":"https://github.com/joe-mclaughlin","@type":"Person","name":"joe-mclaughlin"},"datePublished":"2021-04-28T22:20:19Z","url":"https://github.com/cppcheck-opensource/simplecpp/issues/218"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2c0a60bf-b345-5987-e3cd-8a1cc57dc885 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C92E:19E172:3D33D7:57B323:6AFC5202 |
| html-safe-nonce | f358797518c10b280e363e6b1b4a368c64fa19122a01d6889827a218f1523c15 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTJFOjE5RTE3MjozRDMzRDc6NTdCMzIzOjZBRkM1MjAyIiwidmlzaXRvcl9pZCI6IjcxODI2NTA4ODM4MDc0MDA0NTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | aabaded8fd26c3a0551a38866ea2adc5f648174493fa2f01081bf1f6301caf3d |
| hovercard-subject-tag | issue:870442599 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/cppcheck-opensource/simplecpp/218/issue_layout |
| twitter:image | https://opengraph.githubassets.com/12851036afcb7f31b9ebd16a8ff4fe92966e0905284e521c5687305c1aebc081/cppcheck-opensource/simplecpp/issues/218 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/12851036afcb7f31b9ebd16a8ff4fe92966e0905284e521c5687305c1aebc081/cppcheck-opensource/simplecpp/issues/218 |
| og:image:alt | Adding this issue originally posted to the cppcheck forum per @danmar 's request. I am using a third-party peripheral library from the manufacturer of the microprocessor that we are using, and it c... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | joe-mclaughlin |
| hostname | github.com |
| expected-hostname | github.com |
| None | b63557e0027d8014589e873df28328da74a4356701bb1a9eab49dbf012ba8fa6 |
| turbo-cache-control | no-preview |
| go-import | github.com/cppcheck-opensource/simplecpp git https://github.com/cppcheck-opensource/simplecpp.git |
| octolytics-dimension-user_id | 278097703 |
| octolytics-dimension-user_login | cppcheck-opensource |
| octolytics-dimension-repository_id | 33434464 |
| octolytics-dimension-repository_nwo | cppcheck-opensource/simplecpp |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 33434464 |
| octolytics-dimension-repository_network_root_nwo | cppcheck-opensource/simplecpp |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0243355b0352c83733a042e0dfb3d75149b51261 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width