pre-ansi declarations

c

    Sponsored Links

    Next

  • 1. Telnet pc under NAT
    I am planning to design a VPN application. I am looking for basic concepts involved. Suppose i want to telnet to apc under Dynamic NAT. For this i use a client on this PC so that it initiates an outbound connection. Server on the othern side recieves this request, telnets to the pc. In this scenario, wat shud b the program that opens a socket for the server on the way back connection. Will java sockets will be effective in this case? wat shud be done?
  • 2. !!, what is it?
    hello, I've stumbled upon this in some code: n = !!x; I've ran it and 'n' is always either 0 or 1. Is '!!' an operator (what's it called?) and is it standard/portable? -- b e n k i b b e y ::: bjk AT arbornet DOT org
  • 3. Anyone able to understand this C program?
    Gurus, One of my friend mailed me this sample piece of code: #include <stdio.h> main() { int a,b,c; int count = 1; for (b=c=10;a="- FIGURE?, UMKC,XYZHello Folks,\ TFy!QJu ROo TNn(ROo)SLq SLq ULo+\ UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^\ NBELPeHBFHT}TnALVlBLOFAkHFOuFETp\ HCStHAUFAgcEAelclcn^r^r\\tZvYxXy\ T|S~Pn SPm SOn TNn ULo0ULo#ULo-W\ Hq!WFs XDt!" [b+++21]; ) for(; a-- > 64 ; ) putchar ( ++c=='Z' ? c = c/ 9:33^b&1); return 0; } I compiled the above program with visual studio and got a map of india printed on the output screen. I am underloss to understand how this program works.This seems cryptic to me.Iam wondering whether those char in for loop of (b=c=10;a=....) is ascii char? This is not definitely a homework as some might think.Jus for my curiosity would like to know abt this. Advanced thanks for all your replys, Regards, s.subbarayan
  • 4. 1 more doubt !
    firstly, i am thankful to all those who answered the 1st set of doubts. And i am not yet enlightened to that extent , coz ' i keep getting doubts. is the following defined in the language ?? int main() { int a = 1; int *p = &a; p++; printf("%d",*p); return 0; } thanking you, ranjan.
  • 5. Making a lite version
    Sorry if this is off-topic. At work we have a database program that is very cumbersome to use, which i think is written in C. Are there any programs available that will let me make my own version by linking buttons and fields from various screens onto one form, which when i update will then transfer the data back into the main application? There are about 15 different screens in the main program, but we only use 2/3 fields from 6/7 of the screens. This is to save time jumping through all the screens to put in the basic info we require. thanks for any advice. George

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