OK, I'm new here and new to C. I'm using the DJGPP (GNU) setup to
learn C. I'm having some difficulty accessing a structure ,which I
believe I defined globally, inside a function.
Here's the list of files I'm working with:
DOS_BAT BAT
DOS_MAK BAT batch file to run MAKE
DOS_XXXX MAK MAKE file
386_XXXX C x86 specific routines
386_XXXX H x86 specific routine header file
DOS_XXXX C DOS text interface
BD_XXXX C basic engine data
BD_XXXX H
ENV_XXXX C basic environmental data
ENV_XXXX H
BM_XXXX C basic math routines
BM_XXXX H
CMB_XXXX C combustion chamber routines
CMB_XXXX H
The structure is defined in bd_xxxx.h as follows:
struct engine {
float bore;
float stroke;
float con_rod_len;
unsigned short num_cyl;
float comp_ratio;
float int_open;
float int_close;
float int_valve_lift;
float int_valve_dia;
unsigned short num_int_valve;
float int_port_dia;
float exh_open;
float exh_close;
float exh_valve_lift;
float exh_valve_dia;
unsigned short num_exh_valve;
float exh_port_dia;
float carb_thr_size;
unsigned short num_carb;
char note_1[70];
char note_2[70];
char note_3[70];
char note_4[70];
char note_5[70];
};
typedef struct engine ENGINE;
ENGINE cur_engine;
Now in bm_xxxx.c I have a function that uses bore and stroke to
compute cylinder volume:
void cyl_volume(ENGINE *ptr_engine)
/*float cyl_volume(ENGINE *ptr_engine) */
/* float cyl_volume(*ptr_engine) */
/* float cyl_volume(void) */
{
float cyl_vol = 0.0;
/* cyl_vol = PI * pow((ptr_engine->bore/2), 2) * ptr_engine-
>stroke; */
locate(15,5);
cyl_vol = &(*ptr_engine.bore);
printf("bore - %2.6f", cyl_vol);
/* return cyl_vol; */
pause(0);
}
The commented out definitions are things I've tried. When I try to
compile this, I get:
parse error before *
and
ptr_engine not defined
Any help would be appreciated.
Willy
To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.
| Yahoo! Groups Sponsor |
| Get unlimited calls to U.S./Canada |
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/c-prog/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
