News:

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

Main Menu

ifndef problem

Started by jimg, June 25, 2017, 03:08:59 AM

Previous topic - Next topic

jimg

The following works in Masm-

dbguselib macro libname:req
    ifndef @CatStr(libname,<_INC>)
        include    libname.inc
        includelib libname.lib
    endif
endm

dbguselib kernel32


but in UAsm, it fails with the error-

test.asm(14) : Warning A4249: IF[n]DEF expects a plain symbol as argument: @CatStr(kernel32,<_INC>)


I have a work around for now, but it probably should be fixed I think.

jj2007

It's a warning, not an error. Did you specify some option that elevates warnings to errors?

Btw this suppresses the warning, too:
    % ifndef @CatStr(libname,<_INC>)

jimg

I used my standard   /nologo /c /coff /Cp /Fl /Sn /Sg
It seems it didn't work.
What would be the setting to make warnings fatal/not fatal?
And if it knew how to do it and it did work, why would it bother to give me a warning?
UAsm produced a .err file with these warnings, so it's assumed there was an error, otherwise, warnings just go in the list file I think.
????

jj2007

With your code and your commandline options, Uasm32 of 20.6.17:Tmp_File.asm(10) : Warning A4249: IF[n]DEF expects a plain symbol as argument: @CatStr(kernel32,<_INC>)
dbguselib(1)[Tmp_File.asm]: Macro called from
  Tmp_File.asm(10): Main line code
Tmp_File.asm: 27 lines, 2 passes, 140 ms, 1 warnings, 0 errors


What exactly does the .err file say?

>What would be the setting to make warnings fatal/not fatal?
-WX

HSE

Quote from: jj2007 on June 25, 2017, 03:51:39 AM
Btw this suppresses the warning, too:
    % ifndef @CatStr(libname,<_INC>)

Just to say something  :biggrin:: the expansion is not suppressing the warning, but solving the problem.
Equations in Assembly: SmplMath

jimg

You didn't get an error file when you tried it????
  The .err file contains exactly what you said-

test.asm(14) : Warning A4249: IF[n]DEF expects a plain symbol as argument: @CatStr(kernel32,<_INC>)
dbguselib(1)[test.asm]: Macro called from
  test.asm(14): Main line code

It is my understanding that if a .err file exists, the rest of the build process is aborted.  I will have to check more closely.

jj2007

Quote from: jimg on June 25, 2017, 09:30:09 AMIt is my understanding that if a .err file exists, the rest of the build process is aborted.  I will have to check more closely.

Check if .obj and .exe got created. It is really just a warning, there is no error.

jimg

Okay, try this.

try dbguselib masm32

then try one of the masm32 function like dwtoa or something.

Not only will you get the warning above, you will get -

F:\WinAsm\Progs\AllMyStuff\dbgwindow.inc(70) : Error A2160: INVOKE requires prototype for procedure
F:\WinAsm\Progs\AllMyStuff\dbgwindow.inc(70): Included by


meaning, it was not just a warning,  it also did not execute the include and uselib.


habran

If you use % as JJ suggested it will work properly. I can create override for -Zne option if you insist but I'll leave it as it is now without that option, because I am not sure if it can cause some other damage  to the rest of the code until it is tested properly.
The fix can be done in condasm.c starting from line 400:

        if ( tokenarray[i].token != T_FINAL ) {
          if (Options.strict_masm_compat){  /* Zne */
            goto escape;
               EmitWarn( 2, IFDEF_EXPECTS_SYMBOL_ARGUMENT, tokenarray[i-1].tokpos );
               while ( tokenarray[i].token != T_FINAL )  i++;
        }
        if ( directive == T_IFNDEF || directive == T_ELSEIFNDEF )
            NextIfState = ( ( NextIfState == BLOCK_ACTIVE ) ? BLOCK_INACTIVE : BLOCK_ACTIVE );
        break;
    default: /* ELSE and ENDIF */
        NextIfState = BLOCK_ACTIVE;
        break;
    }

    if ( tokenarray[i].token != T_FINAL ) {
        return( EmitErr( SYNTAX_ERROR_EX, tokenarray[i].strskipr ) );
    }
escape:
    CurrIfState = NextIfState;

    DebugMsg1(("CondAsmDirective(%s) exit, state=%s, lvl=%u, falselvl=%u\n",
               GetResWName(directive, NULL), GetCurrIfStatString(), blocknestlevel, falseblocknestlevel));
    return( NOT_ERROR );
}


and this will create escape for rejecting the brackets:
          if (Options.strict_masm_compat){  /* Zne */
            goto escape;

If you are in hurry use that fix or JJ's alternative until we recheck everything and include in next release

Cod-Father

jimg

Thank you.  It's easy for me to make a work around, I just started this thread because I thought it was an inconsistency that should be addressed.  At your leisure or whatever you decide, I'm okay.  At least until the next time it comes up and I've totally forgotten what went on.

jj2007

Quote from: jimg on June 25, 2017, 11:53:30 AM
meaning, it was not just a warning,  it also did not execute the include and uselib.

OK, in that case it's more serious: A warning only for ifndef but errors for the unavailable PROTOs. I wonder, though, why your IDE doesn't signal that clearly. RM stops assembly when it finds the word Error in the build output, and it puts the cursor right into the line of the source where the error occurred. Many IDEs do that, I suppose.

I have quite a number of % IF whatever in MasmBasic, that was an issue already with JWasm. OTOH, one could blame buggy MASM for not handling that correctly ;)

habran

JJ, I believe that this is one of masm "features" and that % IFNDEF should be a correct way
In jimg's case after warning UASM goes to the end of the tokenarray and skips to resolve the macro:

               EmitWarn( 2, IFDEF_EXPECTS_SYMBOL_ARGUMENT, tokenarray[i-1].tokpos );
               while ( tokenarray.token != T_FINAL )  i++;
Cod-Father

jimg

Quote from: jj2007 on June 25, 2017, 06:26:50 PM
Quote from: jimg on June 25, 2017, 11:53:30 AM
meaning, it was not just a warning,  it also did not execute the include and uselib.

OK, in that case it's more serious: A warning only for ifndef but errors for the unavailable PROTOs. I wonder, though, why your IDE doesn't signal that clearly. RM stops assembly when it finds the word Error in the build output, and it puts the cursor right into the line of the source where the error occurred. Many IDEs do that, I suppose.

Mine certainly stops when there is an error and puts you on the error in the code, but these were warnings that also stopped everything.  In my original case I had already loaded the libraries in a different section of code, so there were no missing protos.  The problem was that the warnings stop the auto execution of the exe produced and I can find no IDE settings to say ignore warnings and proceed with execution.   Normally that's a good thing because a warning is a possible problem that should be addressed.  In this case, it was just an annoyance since it was a simple catstr that should have been working without % overides, and I thought it should probably be fixed.
I'm sorry for being prickly lately, I'm about six levels deep in fixing problems or creating tools for a project I started nine months ago, and I fear I've lost sight of my original objective.  The older I get, it gets much more troublesome and irritating to keep track of so many pieces at the same time anymore.

jj2007

Quote from: jimg on June 25, 2017, 11:33:48 PMThe older I get, it gets much more troublesome and irritating to keep track of so many pieces at the same time anymore.

I can confirm that :P

rrr314159

Quote from: HSE on June 25, 2017, 07:38:20 AM
Quote from: jj2007 on June 25, 2017, 03:51:39 AM
Btw this suppresses the warning, too:
    % ifndef @CatStr(libname,<_INC>)

Just to say something  :biggrin:: the expansion is not suppressing the warning, but solving the problem.

Good point, HSE! Sloppy language is one step away from sloppy coding :t

Quote from: jj2007 on June 26, 2017, 12:17:10 AM
Quote from: jimg on June 25, 2017, 11:33:48 PMThe older I get, it gets much more troublesome and irritating to keep track of so many pieces at the same time anymore.

I can confirm that :P

Fortunately, there's a very simple fix for this problem. You just have to stop getting older. See http://lostallhope.com/suicide-methods
I am NaN ;)