This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB 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: testcase for "absolute source" patch


On Wed, Aug 18, 2004 at 11:31:08AM -0400, Michael Chastain wrote:
> Hi Baurzhan,
> 
> bi> 1. Just for my knowledge: I've found the "int main" requirement in C99
> bi>    5.1.2.2.1. But I couldn't find anything about function definitions
> bi>    without a return type defaulting to int (i.e., should the compiler
> bi>    treat the return type as int if it isn't specified?). Does C99 and
> bi>    previous standards say anything about that? Is it different for
> bi>    declarations and definitions?
> 
> I don't have copies of the standards documents, so I'm working from
> The C++ Programming Language 2nd Edition, Kernighan and Ritchie.
> To my surprise, I found out that in this book, and presumably in
> the C89 standard, a function with no return type defaults to "int".
> >From section 1.9:
> 
>   "This line also declares that getline returns an int;
>    since int is the default return type, it could be omitted."
> 
> I don't think it's different for declarations and definitions.
> 
> In a normal program, the FSF coding standards would apply.  But a test
> suite is contra-variant.  Anything that is legal C89 and that doesn't
> make gcc give a warning is okay in a test program, and variation is good
> because it exercises different parts of gdb.
> 
> So it's okay to leave your "main" with no return type.
> But take out the "-w" from gdb_compile.

Yes, C89 allows this, and C99 doesn't.


-- 
Daniel Jacobowitz


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