[Haifux] Intermingled code and declarations and gcc

Vadim Eisenberg vadim.eisenberg at gmail.com
Thu Sep 17 15:44:16 MSD 2009


Hi Eli,

Try -std=c99 flag. The C99 standard allows declarations everywhere.

Shana Tova,
Vadim

-----Original Message-----
From: haifux-bounces at haifux.org [mailto:haifux-bounces at haifux.org] On Behalf Of Eli Billauer
Sent: Thursday, September 17, 2009 1:52 PM
To: Haifa Linux Club
Subject: [Haifux] Intermingled code and declarations and gcc

Hello,


I'm trying to compile some code using gcc 2.96 (gcc 3.0.4 gets crazy on some other issue. Haven't tried on gcc 4 yet, but that's a bit far fetched right now).


The offending rows are more or less (edited a bit for clarity):


    /* count number of environment variables currently set */

    unsigned int envar_count;

    for (envar_count=0; envp[envar_count] != NULL; envar_count++);

    char *child_envp[envar_count];


Apparent problem: The compiler doesn't like the char declaration following "real" code. Can't move the declaration before it, because the array's size depends on the result of the code.


I would be so happy if someone popped up and said, "just use the -something flag".


Anyone?


Shana Tova,

    Eli

-- 
Web: http://www.billauer.co.il

_______________________________________________
Haifux mailing list
Haifux at haifux.org
http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux




More information about the Haifux mailing list