News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

RC File C Syntax

Started by dedndave, October 12, 2013, 07:06:37 AM

Previous topic - Next topic

dedndave

in assembler, we can assign integer constants to symbols with EQU
CONST1 EQU 1
CONST2 EQU 2

then, add 2 of them together to form a new constant which is the summation of the original values
CONST3 EQU CONST1+CONST2

that doesn't seem to work in an RC file
#define  CONST1  1
#define  CONST2  2
#define  CONST3  CONST1+CONST2

it appears to assign CONST3 the string value, "CONST1+CONST2"

i tried using "const" - no luck
const int CONST3 = CONST1+CONST2

tried this one with and without ';'
const int CONST3=(CONST1+CONST2);

what's the correct C syntax ?

jj2007

From a header file:
#define ITSS_THREAD_TIMEOUT_NO_CHANGE        (INFINITE - 1)

Maybe #define  CONST3  (CONST1+CONST2) ?

Gunther

Dave,

const is a C++ construct, but you can use it with C and that has advantages. The compiler has the chance for type checking. That's one side of the coin. On the other hand, the value of such a constant won't change during the program.

Quote from: dedndave on October 12, 2013, 07:06:37 AM
const int CONST3 = CONST1+CONST2

Your CONST3 isn't constant.

Gunther
You have to know the facts before you can distort them.

dedndave

#define  CONST3  (CONST1+2)
probably works

#define  CONST3  (CONST1+CONST2)
doesn't

no wonder i don't like C 

dedndave


qWord

Quote from: dedndave on October 12, 2013, 07:06:37 AMwhat's the correct C syntax ?
RC is not C!
Quote from: About Resource FilesThe syntax and semantics for the RC preprocessor are similar to those of the Microsoft C/C++ compiler. However, RC supports a subset of the preprocessor directives
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

oopss - i spoke too soon
those don't work

jj2007

Quote from: jj2007 on October 12, 2013, 08:33:48 AM
Maybe #define  CONST3  (CONST1+CONST2) ?

Works like a charm:
#define Con1 10
#define Con2 20
#define Con3 (Con1+Con2)

STRINGTABLE
BEGIN
  Con2   "Нажмите на эту кнопку"   ; "Click on this button" in Russian
  Con3   "Добро пожаловать"   ; "Welcome" in Russian
END

dedndave

and - in the asm source, you access the resource with the value 30 ?
that doesn't work for me
i am using RC version 5.00.1823.1

hutch--

The reason why I have never used the double equate system is I am too lazy to write the second set and have to maintain 2 synchronised sets of equates. I LIKE numbered resources.  :greenclp:

dedndave

well - the resource compiler seems to agree with you - lol

i was just trying to keep my apples lined up with my oranges

RT_CURSOR       EQU 1
RT_ICON         EQU 3
DIFFERENCE      EQU 11
RT_GROUP_CURSOR EQU RT_CURSOR+DIFFERENCE
RT_GROUP_ICON   EQU RT_ICON+DIFFERENCE

#define RT_CURSOR       1
#define RT_ICON         3
#define RT_GROUP_CURSOR 12
#define RT_GROUP_ICON   14

doesn't give me a warm-fuzzy feeling   :(

if we're going to play that game, why not...
RT_CURSOR       EQU 1
RT_ICON         EQU 3
RT_GROUP_CURSOR EQU 12
RT_GROUP_ICON   EQU 14


in WinUser.h....
#define RT_GROUP_CURSOR MAKEINTRESOURCE((DWORD)RT_CURSOR+DIFFERENCE)

seems like a lot of text to add 2 values together   ::)
and, RC doesn't seem to provide support for the MAKEINTRESOURCE macro

assembly language kicks ass   :t
now, if we can just convince the other 99%