pre-ansi declarations

c

    Sponsored Links

    Next

  • 1. Any function to change windows start menu shortcut properties ?
    I have to change the tartget property of a windows start->Program->X's shortcut properties using c program. Do we have any function for that ? please reply me ASAP.. as it is urgent !
  • 2. read in file offset
    Hiya, Im working on a project to read in a file (its a bitmap, but thats irrelevant) and I want to read in all the data after an offset, ive tried using - fread(bitmap_buffer, offset, 1, fp); but this doesnt work and only reads in the value at the offset (0x436h irrelevant once again i suppose). so my question is how do i read in all the data AFTER a certain offset, into my buffer? any help much appreciated, and no this isnt school work (school terms out anyway) Im just doing this becuase im learning to program and starting to enjoy writing programs that can do useful stuff :-) thanks
  • 3. : Sizeof and increment operators
    The ISO C standard has carefully defined sizeof so that it can be evaluated to a constant during parsing. The operand of a sizeof operator is usually not evaluated (6.5.3.4). Regards, Amit Kulkarni

pre-ansi declarations

Postby j0mbolar » Thu, 09 Feb 2006 10:41:52 GMT

Which sections in the standard mandate that 'foo' below does
not qualify as a function that includes a prototype:

void foo(a)
 char *a;
{
    do_something(a);
}

int main(void)
{
    foo();
    return 0;
}



also, under 6.11.2 of c99, how is it possible
to declare a file scope object with internal linkage
without using 'static'?


Re: pre-ansi declarations

Postby Keith Thompson » Thu, 09 Feb 2006 11:04:59 GMT

"j0mbolar" < XXXX@XXXXX.COM > writes:

Probably the definition of "function prototype" in 6.2.1p2:

    A _function prototype_ is a declaration of a function that
    declares the types of its parameters.

The *definition* of foo() declares the type of a; the *declaration*
doesn't.


I don't know.  Anybody else?

-- 
Keith Thompson (The_Other_Keith)  XXXX@XXXXX.COM   < http://www.**--****.com/ ~kst>
San Diego Supercomputer Center             <*>  < http://www.**--****.com/ ~kst>
We must do something.  This is something.  Therefore, we must do this.

Re: pre-ansi declarations

Postby j0mbolar » Thu, 09 Feb 2006 11:20:17 GMT




So where default argument promotions do not apply,
do pre-ansi compilers infer the type in the above example
from 'a', so that they know it is a 'pointer to char'?


Re: pre-ansi declarations

Postby Keith Thompson » Thu, 09 Feb 2006 11:51:02 GMT

"j0mbolar" < XXXX@XXXXX.COM > writes:



Within the function, the declaration of a is visible, so the compiler
knows it's a char*.

For a call, the compiler doesn't know what type of argument the
function expects, so it's up to the caller to pass the right type.
It's similar to what happens with printf-like functions.

-- 
Keith Thompson (The_Other_Keith)  XXXX@XXXXX.COM   < http://www.**--****.com/ ~kst>
San Diego Supercomputer Center             <*>  < http://www.**--****.com/ ~kst>
We must do something.  This is something.  Therefore, we must do this.

Re: pre-ansi declarations

Postby Eric Sosman » Fri, 10 Feb 2006 00:57:04 GMT


j0mbolar wrote On 02/07/06 20:41,:

    Perhaps 6.11.2 is referring to the situation described
in 6.2.2/4:

	/* at file scope: */
	static int x;   /* internal linkage */
	...
	extern int x;   /* internal linkage, obscolescent(?) */

-- 
 XXXX@XXXXX.COM 


Re: pre-ansi declarations

Postby j0mbolar » Fri, 10 Feb 2006 06:01:45 GMT




What would make that obsolescent? And technically,
this would involve the use of 'static' in making it
have internal linkage. It is just that the latter declaration
does not inhibit the former's meaning.


Re: pre-ansi declarations

Postby j0mbolar » Fri, 10 Feb 2006 06:05:20 GMT




I meant to set follow-ups to comp.std.c

What do the committee members in comp.std.c
have to say about this?


Re: pre-ansi declarations

Postby Antoine Leca » Fri, 10 Feb 2006 23:39:29 GMT



Can you elaborate?

If you mean
    static int x;
    int x;
I read 6.2.2p5, 2nd sentence as making x of external linkage, and the
combination of both lines is UB by 6.2.2p7.

This text is unchanged since C89 (I thought a DR had added something, so
checked, and turned empty.)


Antoine


Re: pre-ansi declarations

Postby Antoine Leca » Fri, 10 Feb 2006 23:41:47 GMT


j0mbolar va escriure:

What: the Standard, the very 6.11.2.

Why: because when you are looking only at the second line (arbitrarily far
from the first), you do not immediately notice that the identifier is not
visible outside this translation unit.

Making this obsolescent is (was really) a free card for the committee to
revoke such a possibility in the future. It is also a strong hint the above
is "bad style."


Antoine


Re: pre-ansi declarations

Postby kuyper » Sat, 11 Feb 2006 00:15:27 GMT





You should be aware that the following counts as a declaration of
foo():


while everything from here on in is only part of the definition of
foo(); it's not part of the declaration.
A declaration that is only a declaration, and not a definition, could
be present in one translation unit, while the actual definition of the
function might be in an entirely different translation unit.


No; they handled such code in pretty much the same way as it's
currently handled. The definition of 'a' that is provided as part of
the definition of foo() has significance only inside the definition of
foo(); it has no effect on the interpretation of calls to foo(). If the
promoted type of an argument is incompatible with the actual type of
the corresponding parameter, you've got trouble; there's no implicit
conversion to the specified type, because in the absence of a
prototype, there is no specified type. There's also no mandatory
diagnostic to warn you of the problem. That's why prototypes were
invented.


Similar Threads:

1.pre-ansi declarations

Eric Sosman wrote:
> j0mbolar wrote On 02/07/06 20:41,:
> > Which sections in the standard mandate that 'foo' below does
> > not qualify as a function that includes a prototype:
> >
> > void foo(a)
> >  char *a;
> > {
> >     do_something(a);
> > }
> >
> > int main(void)
> > {
> >     foo();
> >     return 0;
> > }
> >
> >
> >
> > also, under 6.11.2 of c99, how is it possible
> > to declare a file scope object with internal linkage
> > without using 'static'?
>
>     Perhaps 6.11.2 is referring to the situation described
> in 6.2.2/4:
>
> 	/* at file scope: */
> 	static int x;   /* internal linkage */
> 	...
> 	extern int x;   /* internal linkage, obscolescent(?) */
>

I meant to set follow-ups to comp.std.c

What do the committee members in comp.std.c
have to say about this?

2.[ANNOUNCE] wxAda (pre-pre-pre-pre-release)

Hi,

Just thought I'd post a little note about the status of the project. I
have uploaded the source to Tigris. This is not complete and I have
stalled. I have recently stumbled across major blocks which I need help
with. Or if somebody wants to take over leading development, I have no
problem with that; my future with wxAda isn't too clear to me at the
moment.

The source isn't in the best way, but it does build with wxWidgets
2.6.3 and does provide some functionality.

Please feel free to look over the project and see what can be done.

Thanks,
Luke.

3.wxAda (pre-pre-pre-pre-release)

4.pre ANSI code and writable-strings?

char *s = "Hello";
s[0] = 'J';
puts(s);

might print "Jello" in a pre-ANSI compiler - is the behaviour of this 
program undefined in any pre-ANSI compiler - or would it always have printed 
"Jello" with a pre-ANSI compiler?
In gcc with the "writable-strings" option this program prints
Jello
If there were more than one semantics for what this progran did under a 
pre-ANSI compiler, which semantics were chosen by gcc for the 
"writable-strings" option, and for what reason?



5.Pre-ANSI C functions and .NET browse information symbols

I need to compile a library of C code with pre-ANSI C functions using MS 
.NET 2003. The functions are declared something like this:

int myFunction(p)
double p;
{
  int x;
  code here...
  return x;
}

The compilation proceeds without a glitch but when I tell .NET to build 
browse information for the functions, it seems not to include the pre-ANSI 
functions in browse information.

I could manually make the functions ANSI compliant by changing the code but 
there are 75+ functions. This seems to work for a few functions that I have 
altered. Is there a switch that tells .NET that the functions are pre-ANSI 
style so that it can build the browse information correctly or some other 
way to get the functions into the browse information?

Thanks,
RK


6. Harbour ANSI C sprintf() for ANSI SQL.

7. maxplusII error: a deferred constant declaration without a full declaration is not supported

8. conflicting types or implicit declaration or incompatible implicit declaration



Return to c

 

Who is online

Users browsing this forum: No registered users and 18 guest