Opened 4 years ago

Closed 4 years ago

#6395 closed defect (fixed)

Some generated C code shows up in red in OMedit

Reported by: Francesco Casella Owned by: Adeel Asghar
Priority: high Milestone: 1.17.0
Component: OMEdit Version: 1.18.0-dev
Keywords: Cc:

Description

Simulate model Modelica.Blocks.Examples.Filter. Some red C code lines scroll by, e.g.

Filter_functions.c:28:14: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
  if((_order == ((modelica_integer) 1)))
      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Filter_functions.c:28:14: note: remove extraneous parentheses around the comparison to silence this warning
  if((_order == ((modelica_integer) 1)))
     ~       ^                        ~
Filter_functions.c:28:14: note: use '=' to turn this equality comparison into an assignment
  if((_order == ((modelica_integer) 1)))
             ^~
             =

I understand none of this is really a problem, so it shouldn't really show up in red. Three possible solutions:

  • Only show errors in red, not warnings
  • Do not generate useless parentheses
  • Add the appropriate message suppression flags

Change History (8)

comment:1 by Adrian Pop, 4 years ago

clang wants them gone, gcc warns about ambiguity and suggest to add them :)
So only 1 and 3 are possible.

in reply to:  1 comment:2 by Francesco Casella, 4 years ago

Replying to adrpo:

clang wants them gone, gcc warns about ambiguity and suggest to add them :)

Religion wars are always popular. Good that nobody gets physically hurt by this stuff :)

So only 1 and 3 are possible.

I'd go for 1. I mean, do OMEdit users have reason to worry about compiler warning messages? Maybe not...

comment:3 by Adeel Asghar, 4 years ago

1 is not possible. OMEdit reads the stdout (printed in black) and stderr (printed in red) of simulation executable. Both errors and warnings are sent to stderr. There is no good way to differentiate between them except to do string parsing which I am strongly not in favor of.

in reply to:  3 comment:4 by Francesco Casella, 4 years ago

Replying to adeas31:

1 is not possible. OMEdit reads the stdout (printed in black) and stderr (printed in red) of simulation executable. Both errors and warnings are sent to stderr.

Aha. I was wondering what was the criterion to distinguish them.

There is no good way to differentiate between them except to do string parsing which I am strongly not in favor of.

I agree we shouldn't do parsing, that is a quite deep rabbit hole.

However, showing stuff in red really gives a bad impression, like there is something wrong (which is not true). Maybe you could simply call strfind on each line with some keyword strings, e.g. "remove extraneous parentheses" or "turn this equality comparison", and discard the line if strfind returns true.

What do you think?

comment:5 by Adrian Pop, 4 years ago

We could change the color of stderr but this basically happens in any type of console from Eclipse to Atom. The color of stderr is red.

comment:6 by Adrian Pop, 4 years ago

My suggestion is to add -Wparentheses-equality to the CFLAGS.

in reply to:  6 comment:7 by Francesco Casella, 4 years ago

Replying to adrpo:

My suggestion is to add -Wparentheses-equality to the CFLAGS.

That for sure would help and is not controversial :)

comment:8 by Adrian Pop, 4 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.