This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Test standard function names?


Phil Edwards wrote:

On Sat, Sep 14, 2002 at 02:00:18PM -0600, Kevin Handy wrote:

Would it be possible to have an error displayed when someone tries
to define a function with the name of one of the standard library
function names?

That would be nice for many reasons, but it's not going to happen soon.
For one thing, it's a lot of work. You didn't mention what language you
had in mind, but there are /many/ names in the C standard library, and
/many many/ in the C++ standard library

I was thinking C mostly. C++, maybe, but with it's polymorphic functions
would make things a lot harder. Other languages, like BASIC and
PASCAL, don't have the problem quite as bad because they usually
reserve the common globals names and access them through language
syntax instead of function calls.

I was thinking of a table that could be searched at the start of processing
a function body to see if the name was there.  Parameters/return types
would be ignored.

You would only want to display the error when
the function body was there, so that prototypes wouldn't trigger
the message.

Other things besides functions can collide. This gets tricky quite fast.

Even if only the functions were spotted, it would help a lot.  This comes up
more often in older code whaich has not been updated to the latest version
of the standard, and new code where the user doesn't know every single
reserved function name. It may not cause problems on one platform, but
when moved to another it causes serious problems,

Sometimes a function gets created which didn't exist in one version of C,
but the name was later taken over by a later standard.  It's especially bad
when the users function is close, but different from the one defined in the
standard, for example one that returns NAN instead of 0 for bad vales,
messing of  'if (xxx == 0)' tests in the code.

There would be a need to turn off the message so
that those writing the system library wouldn't have to see it.

Well, first, this warning probably woudln't be on by default. And secondly,
all the warning options come with a way fo turning them off, just by virtue
of the way they're parsed. Every -Wfoo has a -Wno-foo.

Thinking more of having it turned on with some of the all-encompasing
options like 'Wall' & friends.


Phil






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]