swig / swig

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.
http://www.swig.org
Other
5.8k stars 1.24k forks source link

Deprecate %typedef #3019

Open ojwb opened 2 months ago

ojwb commented 2 months ago

SWIG accepts %typedef but just treats it as an SWIG-specific alias for typedef (and poking git history this seems to be true as far back as we have useful history). It's not documented and has no test coverage. The only mentions outside the source code are in two CHANGES entries from 1996:

  1. %typedef modified to insert a corresponding C typedef into the output file.

  2. Better implementation of %typedef directive.

This feature seems to serve no useful purpose, but I spotted a use "in the wild":

https://sources.debian.org/src/soapysdr/0.8.1-5/python/SoapySDR.in.i/?hl=105#L105

That one looks to me like it's just a typo (or thinko) for typedef that SWIG quietly accepted so the developer didn't notice.

I think it make sense to deprecate this, and either just remove it, or emit a warning (and actually remove it in a few years). The recommended solution would be just to use typedef instead, which should work with existing SWIG versions going back a long way.

@wsfulton Thoughts?

ojwb commented 2 months ago

I found more uses of %typedef:

(Also xapian-bindings, which I maintain so I've pushed a fix for that one.)

That's from searching sources packaged for Debian (which was a bit noisy due to unrelated %typedef in other things). There are likely more in FOSS code not packaged and proprietary projects, so I think this probably argues against just ripping it out.