Hello
I have a question to use a one constant string in Asm and RC files?
In Cpp can i use a include like this
Constant.h
#define ConstString "abcd"
Rc file
#include "Constant.h"
some code ConstString
In C/Cpp file to
#include "Constant.h"
int main(int argc, char* argv[])
{
printf("My const string is: %s " ConstString "\n");
Is it possible to write a macro to convert the #define
#define ConstString "abcd"
to
ConstString db "abcd",0
and use it in Masm code?
I know #define give error by compile but is there a solution?
Regards,
Hi Ragdog!
I think You can replace #define with STRING using some editor, like RadAsm. But you have to add a coma manually after string's name.
include \masm32\include\masm32rt.inc
MyData equ <"Hello World">
.data
HelloW$ db MyData, 0
.code
start:
MsgBox 0, offset HelloW$, "That was easy!!", MB_OK
exit
end start
Hello
@HSE yes i know i can use a editor to replace but this is not my goal
@Jochen too
I ask it is possible to use a macro to change it.
Thanks you both for reply
Regards,
The macro itself is fairly straightforward but masm chokes if you call it #define
Doesn't seem to like the # character.
I would be inclined to think that,
#define ConstString "abcd"
would become
ConstString equ <abcd>
or
ConstString equ "abcd"
Without looking it up, perhaps a TEXTEQU.