Issue Details (XML | Word | Printable)

Key: PCC-175
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Daniel Dickman
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
pcc

pcc has problems with extern inline

Created: 30/Oct/10 07:00 PM   Updated: 30/Oct/10 10:31 PM
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

Environment:
OpenBSD 4.8-current (GENERIC) #308: Fri Oct 29 12:55:14 MDT 2010
    deraadt@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC

pcc 0.9.9 for x86_64-unknown-openbsd4.8, xxx@xxx.xxx.xxx Sat Oct 30 12:49:53 EDT 2010


gcc (GCC) 4.2.1 20070719


 Description  « Hide
latest pcc seems to choke on "extern inline". But this works on gcc. I'm not sure what the official spec says should happen here. Here's a test case --


---[ func.h ]---------------------------------
#ifndef FUNC_H
#define FUNC_H

#include <stdio.h>

extern inline int some_function();

extern inline int some_function()
{
        printf("extern some_function\n");
        return 0;
}

#endif


---[ func.c ]---------------------------------
#include "func.h"

int some_function()
{
        printf("some_function\n");
        return 0;
}

int main(int argc, char** argv) {
        return some_function();
}
---[ pcc func.c ]---------------------------------
func.c, line 4: redeclaration of some_function


---[ gcc func.c ]---------------------------------

---[ output of running ./a.out which was compiled with gcc ]---------------------------------
some_function



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 30/Oct/10 10:31 PM
This behavior is as it is intended to. Note that gcc do not follow C99 specifications when it comes to inline:

- In C99 declaration of "extern inline" will create a function with external linkage (i.e. a normal function).
- In gcc "extern inline" will make a function that is only inlined, no external linkage.

Pcc follows C99 strictly, but accept the gcc compat attribute gnu_inline which tells that an inline function shall obey gcc syntax.
Also, the define __GNUC_STDC_INLINE__ can be checked whether the inlining is c99 or gcc.

In newer gcc using -std=c99 will make it use c99 syntax. It's not default though.