News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

What to do if two files I include define the same things?

Started by assembler, February 24, 2017, 12:25:22 PM

Previous topic - Next topic

assembler

What to do if two files define the same things?

I have a problem when I do:

includelib \masm32\lib\msvcrt.lib

The linker links msvcrt.dll, where there is the code and implementation of the printf procedure, but to invoke it in my code, I must define as:

printf proto C :vararg

but when I also do

include \masm32\macros\macros.asm

I get the error "redefinition symbols: printf", so I can't either include this asm file anymore or invoke printf anymore, if I delete the line

printf proto C :vararg

Because if I try to invoke printf anywhere in my code then I get this weird error: "Invalid symbol type in expression."

But in general, if two include files do define the same thing, what should I do to avoid the redefinition error?

For instance if "file A.inc" defines "foo" procedure and "file B.inc" also defines "foo" procedure, but with different implementation, then how do I control which foo to invoke instead of getting the redefinition error? How in my code I invoke foo that came from "file A.inc"? or to invoke foo that came from "file B.inc"? If both files define the same proto, I want to tell the assembler to ignore all the repeating lines that redefines the existing symbol, instead of erroring me "redefintion symbols". There exist solution to the redefinition symbols problem, in theory, and I want to know how do I get to this solution.

hutch--

You simply cannot use 2 versions of the same name. To use the DLL version AND avoid naming conflicts you use the prefix "crt_"

It is defined in MSVCRT.INC in MASM32.

    externdef _imp__printf:PTR c_msvcrt
    crt_printf equ <_imp__printf>

jj2007

Quote from: assembler on February 24, 2017, 12:25:22 PMThere exist solution to the redefinition symbols problem, in theory, and I want to know how do I get to this solution.

Again, the only place where that theory is defined is the Micros**t MASM manual. A good read btw.


mineiro

hello sir assembler, ambiguity;
So, I reach this and inserted others things too, now, we have foo db foo, foo dd foo, foo dq foo, foo proc foo:foo, "foo proc foo2:foo,foo1:foo", well man, it's hard to solve this because scopes, scopes like on a string a tab is just a tab key but on code a tab key acts like a space.
Scopes like foo it's a pointer to a char,  oh no, foo it's a char, nooooop foo it's a function, better no, foo it's a unsigned interger, hmm no, foo it's a real 4, well, foo it's on everywhere, ohh man, foo it's omnipresent hehehe, so I singing in the rain, foo, foo, foo, (of course, 3 diferent words).
The better that you can do is put sensitive case to letters and write diferent foo like Foo, foo, fOo, ... .

You can think on this like the same program name on same path (directory, folder), what program will be called? it's possible? If we have foo.bat, foo.com, foo.exe, foo.scr, foo.dll, foo.sys, ..., what will be the first to be executed?
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

LordAdef


assembler

Quote from: mineiro on February 25, 2017, 01:58:11 PM
hello sir assembler, ambiguity;
So, I reach this and inserted others things too, now, we have foo db foo, foo dd foo, foo dq foo, foo proc foo:foo, "foo proc foo2:foo,foo1:foo", well man, it's hard to solve this because scopes, scopes like on a string a tab is just a tab key but on code a tab key acts like a space.
Scopes like foo it's a pointer to a char,  oh no, foo it's a char, nooooop foo it's a function, better no, foo it's a unsigned interger, hmm no, foo it's a real 4, well, foo it's on everywhere, ohh man, foo it's omnipresent hehehe, so I singing in the rain, foo, foo, foo, (of course, 3 diferent words).
The better that you can do is put sensitive case to letters and write diferent foo like Foo, foo, fOo, ... .

You can think on this like the same program name on same path (directory, folder), what program will be called? it's possible? If we have foo.bat, foo.com, foo.exe, foo.scr, foo.dll, foo.sys, ..., what will be the first to be executed?

Thanks