GCC Warnings for built-in functions (C)

Sharky Forums


Results 1 to 5 of 5

Thread: GCC Warnings for built-in functions (C)

  1. #1
    Hammerhead Shark
    Join Date
    Feb 2001
    Posts
    1,612

    Post GCC Warnings for built-in functions (C)

    I don't know if this happens with other compilers (all I use is GCC), but it seems kinda strange to me. I just wrote a function (strend()). Inside that function, I called my own version of strlen(). I did not #include <string.h> anywhere in the program, so it wouldn't be a problem. (It wouldn't be a problem even if I did include <string.h>, would it?) Anyway, when I compile it, GCC gives me this warning:
    warning: conflicting types for built-in function 'strlen'
    Is this normal? Why would this happen? Oh, and I put main(), strend(), and strlen() all in their own separate files, if that makes a difference.

  2. #2
    Reef Shark
    Join Date
    Apr 2001
    Location
    Austin, TX
    Posts
    371

    Post

    What version of GCC?

    ------------------
    Advocate of the Sharky (Ultra) High-Resolution Club [SHRC]
    main(i){putchar(341513875>>(i-1)*5&31|!!(i<6)<<6)&&main(++i);}
    Advocate of the Sharky (Ultra) High-Resolution Club [SHRC]
    main(i){putchar(341513875>>(i-1)*5&31|!!(i<6)<<6)&&main(++i);}

  3. #3
    Hammerhead Shark
    Join Date
    Feb 2001
    Posts
    1,612

    Post

    I'll check the version tomorrow, since I'm in Windows now and I just want to get to bed. =)


    Anyway, now I'm wondering if GCC even cares about #includes. It seems to me that you have to specify (at the command line) every file that you want to include anyway. (some are always included by default?)

  4. #4
    Reef Shark
    Join Date
    Oct 2000
    Posts
    397

    Post

    Originally posted by Strogian:
    I don't know if this happens with other compilers (all I use is GCC), but it seems kinda strange to me. I just wrote a function (strend()). Inside that function, I called my own version of strlen(). I did not #include &lt;string.h&gt; anywhere in the program, so it wouldn't be a problem. (It wouldn't be a problem even if I did include &lt;string.h&gt;, would it?) Anyway, when I compile it, GCC gives me this warning:
    warning: conflicting types for built-in function 'strlen'
    Is this normal? Why would this happen? Oh, and I put main(), strend(), and strlen() all in their own separate files, if that makes a difference.
    It may be that you've altered the original declaration of strlen. The correct prototype should be something like:

    size_t strlen( const char * );

    where size_t is typically an unsigned int or unsigned long.

    The best and safest way to clear the warning message is to either rename your version of strlen to avoid conflict, or to use the C++ namespace feature.

    [This message has been edited by Conrad Song (edited June 25, 2001).]

  5. #5
    Reef Shark
    Join Date
    Oct 2000
    Posts
    397

    Smile

    Originally posted by Strogian:
    I don't know if this happens with other compilers (all I use is GCC), but it seems kinda strange to me. I just wrote a function (strend()). Inside that function, I called my own version of strlen(). I did not #include &lt;string.h&gt; anywhere in the program, so it wouldn't be a problem. (It wouldn't be a problem even if I did include &lt;string.h&gt;, would it?) Anyway, when I compile it, GCC gives me this warning:
    warning: conflicting types for built-in function 'strlen'
    Is this normal? Why would this happen? Oh, and I put main(), strend(), and strlen() all in their own separate files, if that makes a difference.
    Incidentally, just because string.h is not included does not mean that strlen is not defined. Be careful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •