My code contains function identifiers that are are unique within their
namespace. However, they collide with some builtin function generating a
"conflicting types for built-in function <name>" warning. The project build
will break when using -Werror inspite the code being semantically correct.

I have tried the 3.4.6 compiler with same results. But judging the situation I
expect this to be a conceptual issue.

The switch -fno-builtin=function is not an alternative/solution as this is
conceptually something different. I *want* builtins, but *only* when they have
been marked as such, and that should be when I include appropriate header files
containing their prototypes.

Built-in functions should not exist in global namespace but should only be
activated on demand. Preferable as a part of a function prototype such as in
math.h:

extern double exp2 (double) __attribute__ ((builtin ("exp2")));

The danger of the current (global) approach is that future builds might break
if some application used identifier is included into the list of builtin
functions. Besides, "hardcoding" names is something preferably avoided and I
can imagine situations in where I will stretch programming rules and would like
to have builtins under alternative names {but that is a different topic).

The following is the test code. It does not include math.h so it should not
issue a warning.

--------

#include <stdio.h>

void exp1(void)
{
    printf("Experiment 1\n");
}

void exp2(char* arg1)
{
    printf("Experiment 2\n");
}

void exp3(char* arg1, char* arg2)
{
    printf("Experiment 3\n");
}

int main (int argc, char *argv[])
{
    switch (argc) {
    case 1:
        exp1();
        break;
    case 2:
        exp2(argv[1]);
        break;
    case 3:
        exp3(argv[1], argv[2]);
        break;
    default:
        break;
    }
    return 0;
}


-- 
           Summary: Builtin functions too intrusive causing -Werror build to
                    break.
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: franz at digital-connectivity dot com
 GCC build triplet: athlon-cerberus-linux
  GCC host triplet: athlon-cerberus-linux
GCC target triplet: athlon-cerberus-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31791

Reply via email to