Anonymous | Login | Signup for a new account | 2025-06-18 15:06 UTC | ![]() |
My View | View Issues | Change Log | Roadmap | Doomseeker Issue Support Ranking | Rules | My Account |
View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||||||
0003905 | Doomseeker | [All Projects] Cleanup | public | 2021-09-24 15:40 | 2021-09-28 23:29 | ||||||||
Reporter | WubTheCaptain | ||||||||||||
Assigned To | |||||||||||||
Priority | low | Severity | minor | Reproducibility | have not tried | ||||||||
Status | confirmed | Resolution | open | ||||||||||
Platform | OS | OS Version | |||||||||||
Product Version | 1.3.2 | ||||||||||||
Target Version | Fixed in Version | ||||||||||||
Summary | 0003905: zandronumbinaries.cpp OS-dependent macro hell is quite ugly (and broken) | ||||||||||||
Description | This macro hell was too cumbersome to read for me:Quote from src/plugins/zandronum/zandronumbinaries.cpp#ifdef Q_OS_WIN32 #define TESTING_BINARY_URL TESTING_BINARY_URL_BASE "windows.zip" #define ZANDRONUM_BINARY_NAME "zandronum.exe" #define SCRIPT_FILE_EXTENSION ".bat" #else #ifndef __x86_64__ #define TESTING_BINARY_URL TESTING_BINARY_URL_BASE "linux-x86.tar.bz2" #else #define TESTING_BINARY_URL TESTING_BINARY_URL_BASE "linux-x86_64.tar.bz2" #endif #ifndef Q_OS_DARWIN #define ZANDRONUM_BINARY_NAME "zandronum" #else #define ZANDRONUM_BINARY_NAME "Zandronum.app" #define ZANDRONUM_APP_BUNDLE_BIN "/Contents/MacOS/zandronum" #endif #define SCRIPT_FILE_EXTENSION ".sh" #endif The first Q_OS_WIN32 seems fine. Then the latter confused me. I forgot it's not possible to re-define a macro without undefining it first in C++. This initially led me to believe 64-bit Windows would download GNU/Linux binaries, and use a binary named zandronum instead of zandronum.exe. After copying the code to my text editor and adding spaces, I figured the first Q_OS_WIN32 block doesn't even end in #endif and changed my understanding of the code entirely. With spaces and newlines, the above code is the same as: #ifdef Q_OS_WIN32 #define TESTING_BINARY_URL TESTING_BINARY_URL_BASE "windows.zip" #define ZANDRONUM_BINARY_NAME "zandronum.exe" #define SCRIPT_FILE_EXTENSION ".bat" #else #ifndef __x86_64__ #define TESTING_BINARY_URL TESTING_BINARY_URL_BASE "linux-x86.tar.bz2" #else #define TESTING_BINARY_URL TESTING_BINARY_URL_BASE "linux-x86_64.tar.bz2" #endif #ifndef Q_OS_DARWIN #define ZANDRONUM_BINARY_NAME "zandronum" #else #define ZANDRONUM_BINARY_NAME "Zandronum.app" #define ZANDRONUM_APP_BUNDLE_BIN "/Contents/MacOS/zandronum" #endif #define SCRIPT_FILE_EXTENSION ".sh" #endif Suddenly more understandable (thanks, spaces!), yet still ugly (and broken in some ways). Other issues here, some which may be seperate issues:
| ||||||||||||
Additional Information | src/plugins/zandronumq/zandronumqbinaries.cpp does not have the __x64_64__ macro, no support for GNU/Linux with that plugin I assume. | ||||||||||||
Attached Files | |||||||||||||
![]() |
|||||||||||
|
![]() |
|
WubTheCaptain (reporter) 2021-09-24 15:46 edited on: 2021-09-24 17:54 |
Nevermind I did not do the "if Windows" / "if not Windows" split here, for each OS the first part could look like:#ifdef Q_OS_LINUX #ifndef Q_PROCESSOR_X86_64 #define TESTING_BINARY_URL TESTING_BINARY_URL_BASE "linux-x86.tar.bz2" #else #define TESTING_BINARY_URL TESTING_BINARY_URL_BASE "linux-x86_64.tar.bz2" #endif #define ZANDRONUM_BINARY_NAME "zandronum" #define SCRIPT_FILE_EXTENSION ".sh" #endif #ifdef Q_OS_MACOS #define ZANDRONUM_BINARY_NAME "Zandronum.app" #define ZANDRONUM_APP_BUNDLE_BIN "/Contents/MacOS/zandronum" #define SCRIPT_FILE_EXTENSION ".sh" #endif #ifdef Q_OS_WIN32 #ifndef Q_OS_WIN64 #define TESTING_BINARY_URL TESTING_BINARY_URL_BASE "windows.zip" #else #define TESTING_BINARY_URL TESTING_BINARY_URL_BASE "windows-x64.7z" #endif #define ZANDRONUM_BINARY_NAME "zandronum.exe" #define SCRIPT_FILE_EXTENSION ".bat" #endif It's not as concise and duplicates SCRIPT_FILE_EXTENSION once (can be macroed again to "if Windows" / "if not Windows"), but it's immediately mostly sensible. |
WubTheCaptain (reporter) 2021-09-24 16:28 |
Quote from WubTheCaptain This is also issue 0003906. |
WubTheCaptain (reporter) 2021-09-24 17:12 edited on: 2021-09-24 17:14 |
Quote from WubTheCaptain I had deleted my earlier note here, but the imprecision also implied in OP and incorrectly in the above example is that GNU/Linux on non-x86 processors (e.g. ARM) will still download the x86 binaries, instead of refusing. |
Pol M (developer) 2021-09-28 23:29 |
All the points are logical and make sense, seems good to me |
Only registered users can voice their support. Click here to register, or here to log in. | |
Supporters: | No one explicitly supports this issue yet. |
Opponents: | No one explicitly opposes this issue yet. |
![]() |
|||
Date Modified | Username | Field | Change |
2021-09-24 15:40 | WubTheCaptain | New Issue | |
2021-09-24 15:46 | WubTheCaptain | Note Added: 0021761 | |
2021-09-24 15:59 | WubTheCaptain | Note Added: 0021762 | |
2021-09-24 15:59 | WubTheCaptain | Note Edited: 0021762 | View Revisions |
2021-09-24 16:00 | WubTheCaptain | Note Deleted: 0021762 | |
2021-09-24 16:28 | WubTheCaptain | Note Added: 0021765 | |
2021-09-24 16:28 | WubTheCaptain | Relationship added | related to 0003906 |
2021-09-24 17:12 | WubTheCaptain | Note Added: 0021769 | |
2021-09-24 17:12 | WubTheCaptain | Note Edited: 0021769 | View Revisions |
2021-09-24 17:14 | WubTheCaptain | Note Edited: 0021769 | View Revisions |
2021-09-24 17:35 | WubTheCaptain | Note Added: 0021772 | |
2021-09-24 17:35 | WubTheCaptain | Note Deleted: 0021772 | |
2021-09-24 17:36 | WubTheCaptain | Relationship added | related to 0003908 |
2021-09-24 17:54 | WubTheCaptain | Note Edited: 0021761 | View Revisions |
2021-09-24 18:06 | WubTheCaptain | Description Updated | View Revisions |
2021-09-28 23:29 | Pol M | Note Added: 0021779 | |
2021-09-28 23:29 | Pol M | Status | new => confirmed |
Copyright © 2000 - 2025 MantisBT Team |