pre-ansi declarations

c

    Sponsored Links

    Next

  • 1. string concatenation
    hi all, i am writing a code in which i have a char buffer "cwdir[]" which hold the current working directory by calling the function getcwd(). later i change the directory to "/" as i have to make my code Deamon. and later again i want to run some other executable available at the path holded by the "cwdir[]" using the system() system call. presently i concatenate program name (to be executed) to the "cwdir[]" and use system(chdir)to run the program. do we have any facility to automate this process as i need to run many other programs also using the system() system call for ex as we can use the ## symbol to cancatenate in macro ... --shri
  • 2. help. i dont know how to solve this loop program...using turbo c
    the output should be like this Loop Program -------------------- enter 1st integer: enter 2nd integer: enter 3rd integer: enter 4th integer: enter 5th integer: enter 6th integer: enter 7th integer: enter 8th integer: enter 9th integer: enter 10th integer: =====RESULTS====== sum= average= smallest= largest= no. of odd= no. of even= thank you... please consider this as a challenge.. even though im just a beginner. :Dty.
  • 3. Anyone have any ideas on this one..... (OT) <dea950a7f449b494db5bd497f1306826@localhost.talkaboutprogramming.com> <1189433217.388017.39040@g4g2000hsf.googlegroups.com> <6880987.0f43t3U4RP@ingen.ddns.info> <_smdnZxud4s7jXvbnZ2dnUVZ8vydnZ2d@bt.com>
    "Peter 'Shaggy' Haywood" < XXXX@XXXXX.COM > wrote in message news: XXXX@XXXXX.COM ... > Groovy hepcat Martin Ambuhl was jivin' in comp.lang.c on Sun, 16 Sep > 2007 8:19 am. It's a cool scene! Dig it. > > Re. the ell... > >> The name still is found in the Netherlands, applied to the meter. > > That's metre (with the 'r' before the 'e'), a unit of linear > measurement. A meter (with the 'r' after the 'e') is a device for > measuring something. > > -- > Dig the sig! > > ----------- Peter 'Shaggy' Haywood ------------ > Ain't I'm a dawg!! Your sig rocks. What's up with the subject? < XXXX@XXXXX.COM > -- Wade Ward XXXX@XXXXX.COM "I ain't got time to bleed."

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