Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. #define Macros and the Preprocessor Used by the Resource Compiler

#define Macros and the Preprocessor Used by the Resource Compiler

Scheduled Pinned Locked Moved The Weird and The Wonderful
announcementcomtoolshelpquestion
3 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    David A Gray
    wrote on last edited by
    #1

    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

    R D 2 Replies Last reply
    0
    • D David A Gray

      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

      R Offline
      R Offline
      Rick York
      wrote on last edited by
      #2

      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?"

      1 Reply Last reply
      0
      • D David A Gray

        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

        D Offline
        D Offline
        Dr Walt Fair PE
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups