Author Topic: RC File C Syntax  (Read 4499 times)

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
RC File C Syntax
« on: October 12, 2013, 07:06:37 AM »
in assembler, we can assign integer constants to symbols with EQU
Code: [Select]
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
Code: [Select]
CONST3 EQU CONST1+CONST2
that doesn't seem to work in an RC file
Code: [Select]
#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
Code: [Select]
const int CONST3 = CONST1+CONST2
tried this one with and without ';'
Code: [Select]
const int CONST3=(CONST1+CONST2);
what's the correct C syntax ?

jj2007

  • Member
  • *****
  • Posts: 10108
  • Assembler is fun ;-)
    • MasmBasic
Re: RC File C Syntax
« Reply #1 on: October 12, 2013, 08:33:48 AM »
From a header file:
#define ITSS_THREAD_TIMEOUT_NO_CHANGE        (INFINITE - 1)

Maybe #define  CONST3  (CONST1+CONST2) ?

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: RC File C Syntax
« Reply #2 on: October 12, 2013, 09:05:08 AM »
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.

Code: [Select]
const int CONST3 = CONST1+CONST2

Your CONST3 isn't constant.

Gunther
Get your facts first, and then you can distort them.

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: RC File C Syntax
« Reply #3 on: October 12, 2013, 09:07:34 AM »
Code: [Select]
#define  CONST3  (CONST1+2)probably works

Code: [Select]
#define  CONST3  (CONST1+CONST2)doesn't

no wonder i don't like C 

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: RC File C Syntax
« Reply #4 on: October 12, 2013, 09:33:22 AM »
got it !!!

false alarm

qWord

  • Member
  • *****
  • Posts: 1473
  • The base type of a type is the type itself
    • SmplMath macros
Re: RC File C Syntax
« Reply #5 on: October 12, 2013, 09:42:56 AM »
what's the correct C syntax ?
RC is not C!
Quote from: About Resource Files
The 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

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: RC File C Syntax
« Reply #6 on: October 12, 2013, 09:46:49 AM »
oopss - i spoke too soon
those don't work

jj2007

  • Member
  • *****
  • Posts: 10108
  • Assembler is fun ;-)
    • MasmBasic
Re: RC File C Syntax
« Reply #7 on: October 12, 2013, 04:25:27 PM »
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

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: RC File C Syntax
« Reply #8 on: October 12, 2013, 08:45:39 PM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 7051
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: RC File C Syntax
« Reply #9 on: October 12, 2013, 08:50:35 PM »
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:
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: RC File C Syntax
« Reply #10 on: October 12, 2013, 08:58:06 PM »
well - the resource compiler seems to agree with you - lol

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

Code: [Select]
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...
Code: [Select]
RT_CURSOR       EQU 1
RT_ICON         EQU 3
RT_GROUP_CURSOR EQU 12
RT_GROUP_ICON   EQU 14

in WinUser.h....
Code: [Select]
#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%