pre-ansi declarations

c

    Sponsored Links

    Next

  • 1. CR-NL, NL and ftell
    Hello When opening a CR-NL file, ftell returns the length of the file with the CR-NL as two bytes, is it supposed to do so? I am comparing two file-sizes, one CR-NL and one NL using ftell to get the filesize. Any alternative suggestion is welcomed. Thanks - Martin Johansen
  • 2. what does it do?
    what does it do? #define BLACKBOX(x) ((x)&((x)-1))
  • 3. how to use va_list
    hello, just i want to write a program which can take unknown number of integers and sum these numbers using va_list,va_arg... but, i am not able to recognize the last element in series.can u help in this regard. i want a generalized program , i dont want to terminate my series with 0 or any other pre-determined number. u just tell me how can i recognize the last element. i hv seen at the va_list example given in Turbo C help,but they r using 0 for end of numbers.
  • 4. the algorithm of decimal<->binary conversion
    I'm writing a program for listing all binary numbers of the same length with the same number of 1s. e.g. 0011 0101 0110 1001 1010 1100 my algorithm is as follows... 0. use a formula to calculate the number of numbers 1. temp=1; outputed=0; 2. count from 1 to 2 to the power of the required length 2.1 convert temp to a binary number in a char[] 2.1.1 temp/2 get remainder 2.1.2 blah blah blah......... 2.1.2.1 if no. of 1s == required no., output+1, printf 2.2 temp+1; 2.3 if output>=the value calculated, break it works perfectly... but it seems too slow even when calculating binary numbers of length 20... (as this is a program for the demo online acm contest, time limit is set...) how can I make it more efficient???? Thx~~~~ Mars.
  • 5. HELP:I should in which newsgroup ??
    I ask some ASCII UTF8 questiones in this group. someone say this group doesn't about that topic.But in this group I get more reply then other groups!Or person in this group are more friendly?:) I use c\c++ in Linux.My experience is very poor.So I fall across lot of problems. Could someone tell me I should in which newsgroup to ask my question?Very thanks!!

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 10 guest