Opened 5 months ago

Closed 5 months ago

Last modified 5 months ago

#70253 closed defect (duplicate)

opendx port fails with implicit int error in C99

Reported by: bernstei Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc:
Port: opendx

Description

A bit similarly to ticket 69877 (grace), opendx is failing to compile because the latest compilers enforce C99 no implicit int arguments. Unfortunately, as is apparent from opendx ticket 61842, opendx upstream is entirely abandoned, so it isn't going to be fixed there, but it's very useful for us to be able to keep on using it via macports. If I provide a patch to the opendx Portfile that turns this error into a warning, would someone be willing to incorporate it into macports?

Errors in the log look like

:info:build streamline.c:1262:11: error: parameter 'nDim' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
:info:build NewStream(nDim)

Change History (6)

comment:1 Changed 5 months ago by jmroot (Joshua Root)

Port: opendx added
Resolution: duplicate
Status: newclosed

Ticket #61842 is still open, so I'm closing this since we don't want to have multiple tickets for the same issue. A patch that adds int to the declarations where needed would be accepted.

comment:2 Changed 5 months ago by bernstei

A patch that adds int to the declarations where needed would be accepted.

I'm not sure if that's feasible. For 61842 it was not, because the errors were in code auto-generated by lexx/yacc/bison, and I didn't see any way of manipulating that process. In this case it may be that the code is explicitly in opendx, and may be possible to fix at least in principle, but it's a huge code base, and there could easily be hundreds of instances.

I'll take a deeper look, but given that this is an ancient code that's years (decades?) past any development or support, would it not be acceptable (within macports) to add compiler options to the Portfile to make them behave the way the OpenDX's developers assumed?

comment:3 Changed 5 months ago by bernstei

So, I know this ticket is closed as being a duplicate of 61842, but it is not. Can it be reopened? 61842 involves source autogenerated by lexx/yacc/bison, and I don't think is feasible to fix except by adding compiler flag workarounds. This one involves static source in opendx itself, and may be fixable by updating the source.

I've been looking more carefully, and I've fixed a number of issues, but I can tell you that it's just a mess. For example, it's giving c++11-narrowing errors because of trying to put values > 128 into a char array. It's easy to fix that problem by making it unsigned char, but then there's an error passing it to the relevant X function (XCreatePixmapFromBitmapData in this case), so they have to be cast back to (char *). Anyway, it's manageable so far, but I'd just like to point out that this is a very large and _old_ port, that has many assumptions, now outdated, about how compilers behave.

[edited - there are tens of instances of this particular error - a bitmap stored as raw bits in an array of char instead of unsigned char, but the relevant X functions expecting char *]

I think it's quite likely that it's much more sustainable to set the compilers to behave like their older versions, which the opendx developers assumed, than to update opendx to modern standards. Certainly the resulting patch for this ticket is much smaller that way.

Last edited 5 months ago by bernstei (previous) (diff)

comment:4 Changed 5 months ago by bernstei

FWIW, I now have a static-source patch that allows opendx to compile. 49 changes, including a few arguments no longer implicit, and some char -> unsigned char, and explicit casting.

All that's needed is that file plus adding the patch file to the Portfile.

comment:6 Changed 5 months ago by bernstei

In 7fcdd0ce9e906ef9f9d3db3bbe59290080ddd23f/macports-ports (master):

opendx: fix outdated behavior warning vs. error with clang

Source assumed outdated C/C++ compiler behavior, which clang has
recently switched from warning to errors. Reported as
#70253

  • function arguments that default to int
  • inconsistent function return type
  • values > 128 into a char array
Note: See TracTickets for help on using tickets.