Bug 1270557

Summary: Swig fails to parse macros as types
Product: [Fedora] Fedora Reporter: Antoine Catton <devel>
Component: swigAssignee: Jitka Plesnikova <jplesnik>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 22CC: besser82, jplesnik
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-19 19:19:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Antoine Catton 2015-10-11 05:38:24 UTC
Description of problem:

Can't "pip install M2Crypto" because swig fails to parse C macros in function definitions like this:

%inline %{
int func(MACRO(argument) *arg) {
  return 0;
}
%}

Version-Release number of selected component (if applicable):

$ swig -version 
SWIG Version 3.0.7
$ sudo dnf info swig
Installed Packages
Name        : swig
Arch        : x86_64
Epoch       : 0
Version     : 3.0.7
Release     : 3.fc22
Size        : 5.4 M
Repo        : @System
From repo   : updates

How reproducible:

Every single time.

Steps to Reproduce:
1. $ cat foo.h
#define FOO(name)  struct foo_##name

FOO(bar) {int foo; int bar;};

2. $ cat foo.i
%{
#include "foo.h"
%}
%include "foo.h"

%inline %{
int func(FOO(bar) *foobar)
{
    return 1;
}
%}
3. $ swig -python -I. -modern -includeall -module foo foo.i
foo.i:7: Error: Syntax error in input(1).
zsh: exit 1     swig -python -I. -modern -includeall -module foo foo.i

Actual results:

foo.i:7: Error: Syntax error in input(1).
zsh: exit 1     swig -python -I. -modern -includeall -module foo foo.i

Expected results:

Compiles the python module.

Additional info:

I cloned, compiled and tried with the commit b093d4 of <https://github.com/swig/swig> and it worked.

Comment 1 Jitka Plesnikova 2015-10-16 10:34:59 UTC
I am not able to reproduce the issue. 
I had fresh install Fedora 22 machine with swig and everything worked fine.

swig-3.0.7-3.fc22.x86_64

$ swig -v -python -I. -modern -includeall -module foo foo.i
Language subdirectory: python
Search paths:
   ./
   ./
   ./swig_lib/python/
   /usr/share/swig/3.0.7/python/
   ./swig_lib/
   /usr/share/swig/3.0.7/
Preprocessing...
Starting language-specific parse...
Processing unnamed structs...
Processing types...
C++ analysis...
Generating wrappers...

$ ls
foo.h  foo.i  foo.py  foo_wrap.c

Comment 2 Antoine Catton 2015-10-16 23:29:54 UTC
Jitka,

Thanks for your reply,

That is very interesting. I'm only able to reproduce this error in non-verbose mode. Try to run it without the "-v".

I did run it with "-v" and yes it worked like it did for you. That is a weird bug.

Comment 3 Jitka Plesnikova 2015-10-19 11:58:13 UTC
I tested it also without "-v" and it worked properly

$ ls
foo.h  foo.i
$ swig -python -I. -modern -includeall -module foo foo.i
$ ls
foo.h  foo.i  foo.py  foo_wrap.c

Comment 4 Fedora End Of Life 2016-07-19 19:19:47 UTC
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.