#define Macros and the Preprocessor Used by the Resource Compiler
-
Today, I encountered a problem that appeared to suggest that stringizing behaves differently when headers are fed to the Win32 Resource Compiler,
rc.exe
. My research led me to a post by Raymond Chen, [The Resource Compiler’s preprocessor is not the same as the C preprocessor – The Old New Thing](https://blogs.msdn.microsoft.com/oldnewthing/20171004-00/?p=97126), which included the following comment posted by laonianren at October 5, 2017 at 5:26 am: Stringizing can be persuaded to work in rc files. This converts version numbers into a dotted string suitable for the text part of a version resource:#define STRINGIZE(x) #x
#define EXPAND(x) STRINGIZE(x)
#define MAJOR_VERSION 10
#define MINOR_VERSION 0
#define RELEASE_NUMBER 14393
#define BUILD_NUMBER 0
#define DOTTED_VERSION EXPAND(MAJOR_VERSION) “.” EXPAND(MINOR_VERSION) “.” EXPAND(RELEASE_NUMBER) “.” EXPAND(BUILD_NUMBER)I ultimately discovered that the workaround described above is not only no longer needed, but actually won't work, because the
EXPAND
directive used therein is no longer recognized. With the current tools, you can do this.#define VER_DESCRIPTION_AND_PLATFORM VER_FILE_DESCRIPTION VER_PLATFORM
Though this improvement may be buried in a changelog, it's just as likely that it was quietly fixed, but never reported. The bottom line is that it opens some very cool possibilities, such as incorporating variable text that depends on preprocessor values in standard version resources.
David A. Gray Delivering Solutions for the Ages, One Problem at a Time Interpreting the Fundamental Principle of Tabular Reporting
-
Today, I encountered a problem that appeared to suggest that stringizing behaves differently when headers are fed to the Win32 Resource Compiler,
rc.exe
. My research led me to a post by Raymond Chen, [The Resource Compiler’s preprocessor is not the same as the C preprocessor – The Old New Thing](https://blogs.msdn.microsoft.com/oldnewthing/20171004-00/?p=97126), which included the following comment posted by laonianren at October 5, 2017 at 5:26 am: Stringizing can be persuaded to work in rc files. This converts version numbers into a dotted string suitable for the text part of a version resource:#define STRINGIZE(x) #x
#define EXPAND(x) STRINGIZE(x)
#define MAJOR_VERSION 10
#define MINOR_VERSION 0
#define RELEASE_NUMBER 14393
#define BUILD_NUMBER 0
#define DOTTED_VERSION EXPAND(MAJOR_VERSION) “.” EXPAND(MINOR_VERSION) “.” EXPAND(RELEASE_NUMBER) “.” EXPAND(BUILD_NUMBER)I ultimately discovered that the workaround described above is not only no longer needed, but actually won't work, because the
EXPAND
directive used therein is no longer recognized. With the current tools, you can do this.#define VER_DESCRIPTION_AND_PLATFORM VER_FILE_DESCRIPTION VER_PLATFORM
Though this improvement may be buried in a changelog, it's just as likely that it was quietly fixed, but never reported. The bottom line is that it opens some very cool possibilities, such as incorporating variable text that depends on preprocessor values in standard version resources.
David A. Gray Delivering Solutions for the Ages, One Problem at a Time Interpreting the Fundamental Principle of Tabular Reporting
It was interesting to read Raymond's blog on this. Someone asked me the other day about my style of include guards and my reply was I've been doing it this way for so long I don't remember exactly why. That blog posted reminded me - I didn't have a compiler that supported pragmas back then it was quite a while until "pragma once" existed. FWIW, this is what I do :
#ifndef HEADER_H
#define HEADER_H
#else
#error repeated include of this file
#endif/***
#ifndef HEADER_H
#include "Header.h"
#endif
***/and I ALWAYS have the little commented section so I can copy and paste it and I am always safe. I did this back in the days when a global file change resulted in a compile and build process that took about forty minutes for our system. I cut that down by two thirds by putting this into the headers and I still do it today. I actually got the idea from Microsoft's headers and added the error statement to let me know of offenders. Microsoft still does this today, minus the error. Have a look at afxwin.h for an example.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
-
Today, I encountered a problem that appeared to suggest that stringizing behaves differently when headers are fed to the Win32 Resource Compiler,
rc.exe
. My research led me to a post by Raymond Chen, [The Resource Compiler’s preprocessor is not the same as the C preprocessor – The Old New Thing](https://blogs.msdn.microsoft.com/oldnewthing/20171004-00/?p=97126), which included the following comment posted by laonianren at October 5, 2017 at 5:26 am: Stringizing can be persuaded to work in rc files. This converts version numbers into a dotted string suitable for the text part of a version resource:#define STRINGIZE(x) #x
#define EXPAND(x) STRINGIZE(x)
#define MAJOR_VERSION 10
#define MINOR_VERSION 0
#define RELEASE_NUMBER 14393
#define BUILD_NUMBER 0
#define DOTTED_VERSION EXPAND(MAJOR_VERSION) “.” EXPAND(MINOR_VERSION) “.” EXPAND(RELEASE_NUMBER) “.” EXPAND(BUILD_NUMBER)I ultimately discovered that the workaround described above is not only no longer needed, but actually won't work, because the
EXPAND
directive used therein is no longer recognized. With the current tools, you can do this.#define VER_DESCRIPTION_AND_PLATFORM VER_FILE_DESCRIPTION VER_PLATFORM
Though this improvement may be buried in a changelog, it's just as likely that it was quietly fixed, but never reported. The bottom line is that it opens some very cool possibilities, such as incorporating variable text that depends on preprocessor values in standard version resources.
David A. Gray Delivering Solutions for the Ages, One Problem at a Time Interpreting the Fundamental Principle of Tabular Reporting
I think that this is programming, so I{ll read something else in the Lounge.
CQ de W5ALT
Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software