C problem...se megethos domhs

John Tsiombikas (Nuclear / the Lab) nuclear at siggraph.org
Sun Jan 25 04:13:50 EET 2004


V13 wrote:
> Periergo... Den to'ksera ayto.. Ayto poy *nomizo* oti eixa dei kapoy itan to:
> 
> void koko();
> void lala(void) { koko(1); }
> void koko(int a) {....}
> 
> opoy h dilosh ths synartisis mporei na einai adeia, alla oxi sto orismo tis...

oxi mporei na einai kai o orismos tis, kai ta dyo einai asxima.

> 
> Me ligo psaksimo brika kai ena bug report sto gcc (8 Jun 2002, id: c/6968) poy 
> leei akribos ayto:
> 
> -----
> I might be reading this wrong but does not:
>  
>  An identifier list declares only the identifiers of the parameters of the 
> function. An empty list in a function declarator that is part of a definition 
> of that function specifies that the function has no parameters. The empty 
> list in a function declarator that is not part of a definition of that 
> function specifies that no information about the number or types of the 
> parameters is supplied.124)
>  
>  ( ISO 9899:1999 Section 6.7.5.3 Paragraph 14 )
> 
> mean that in c99 void test() is a function that takes no arguments since 
> enmpty identifier list is part of the function definition and as such the 
> void test() example should produce an error in c99, but doesn't in gcc 3.1 
> using -std=c99
> -----

Nai ayto einai stin C99, alla genikos to thread den anaferotan stin C99 kai 
ypethesa oti kai esy enoouses tin klasiki C kai oxi tin C99, kano lathos ?

> 
> Episis brika mia paragrafo poy leei kati diaforetiko:
> 
> "You can also define a function and not provide argument information. (Do not 
> use this capability in programs that you write: It is retained in Standard C 
> only to support programs written in older C dialects.)"
> 
> kai to:
> -----
> Empty function prototypes are a deprecated feature in C99 (as they were in 
> C89). 
> [C99: §6.7.5.3] 
> -----
...
 > 6.11.6 Function declarators
 > The use of function declarators with empty parentheses (not prototype-format
 > parameter type declarators) is an obsolescent feature.

Nai opos eipa (kai stin C89) theoreite bad style kai mporei na odigisei se 
provlimata, kai as epitrepete.

> 
> Episis den katalabeno pos olo ayto mporei na prokalesei problima stin stiva 
> mias kai sto C calling convention o caller apothikeyei, metabalei kai 
> epanaferei ton stack pointer (kai fysika pernaei tis parametroys stin 
> stiba)...

Nai ontos viastiki diatyposi, ston x86 [1] den tha prokalesei stack corruption 
afou i idia i synartisi den "grafei" stin stoiva prin apo to current stack 
pointer, alla mporei na prokalesei alla provlimata px:

void foo();

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

void foo(void (*bar)()) {
     bar();
}

kai pes mou pou tha pidiksei :)

[1] Alla exe ypopsin sou oti to standard tis C den perigrafei to pos kaleite i 
synartisi, px se merikes arxitektonikes oi parametroi den pernane sto stack alla 
se registers, i den apeteite kan i yparksi stack (an mporei to implementation na 
kanei oti prepei na kanei kai xoris stack). Genikos i C kathorizei symperifora, 
oxi implementation.

-- Nuclear / the Lab --




More information about the Linux-greek-users mailing list