Author Topic: Absent error message when expected  (Read 18758 times)

Offline Serge

  • Jr. Member
  • *
  • Posts: 26
  • Country: ru
Absent error message when expected
« on: February 12, 2010, 03:43:06 PM »
Code follows:

Code: [Select]
%define DEF1 1
%define DEF2 1

%ifdef DEF1
  %ifdef DEF2
    %error "DEF1 and DEF2 may not be defined simultaneously."
  %endif
%endif

%ifdef DEF1
L: aaa
%endif

%ifdef DEF2
L: aad
%endif

When compiled, NASM reports:
Test.asm:15: error: symbol `L' redefined

...and says nothing about myself-defined error. That looks curious.
"%fatal" instead of "%error" works OK.

Offline Cyrill Gorcunov

  • NASM Developer
  • Full Member
  • *****
  • Posts: 179
  • Country: 00
Re: Absent error message when expected
« Reply #1 on: February 12, 2010, 06:26:44 PM »
%error triggers on the final assembly pass only. So due to "redefined" label problem NASM just don't reach final pass.

So you may change your code to something like

%ifdef DEF1
L:   db 0x0
%endif

%ifdef DEF2
J:   db 0x0
%endif

and you should see the %error triggered.

Offline Serge

  • Jr. Member
  • *
  • Posts: 26
  • Country: ru
Re: Absent error message when expected
« Reply #2 on: February 24, 2010, 01:39:42 PM »
Yes, I know. But I wrote exactly what I meant. This is demo-exctract of a larger and more complicated code and I spent more time to find the actual source of problem.

Offline Bryant Keller

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 360
  • Country: us
    • About Bryant Keller
Re: Absent error message when expected
« Reply #3 on: February 24, 2010, 08:11:28 PM »
Cyrill is pointing out that the assembler is finding the redefined 'L' label which causes an error that trumps your user-defined error. This is what the assembler should do. If you commented out either DEF1 or DEF2, no error should be displayed. If you changed your labels to to different names like Cyrill suggested, and kept DEF1 and DEF2 defined then your error should be shown. This is all expected behaviour.

About Bryant Keller
bkeller@about.me

Offline Cyrill Gorcunov

  • NASM Developer
  • Full Member
  • *****
  • Posts: 179
  • Country: 00
Re: Absent error message when expected
« Reply #4 on: February 25, 2010, 05:48:33 PM »
Yes, I know. But I wrote exactly what I meant. This is demo-exctract of a larger and more complicated code and I spent more time to find the actual source of problem.

ok, as Bryant said -- this is done by design. Perhaps the easiest solution for your particular case would be
to use %fatal instead of %error.