[Solved] function declaration in pro*C without body [closed]


This snippet is in the archaic K&R C syntax which predates ANSI C. Then it is indented strangely which makes it look at first glance like you describe, but it really isn’t. calc_options is the function definition with three arguments, the 3rd of which is a pointer options to typedef option_info.

This is the same thing in ANSI C syntax, so it is easier to read:

int calc_options(int currArgc, char *currArgv[], option_info *options)
{
  int optChar;
  int invopt=0;
  while ((optChar = getopt(currArgc, currArgv, ":s:")) != -1 && !(invopt))
  {}
  /* other commands */
}  

“option_info is defined as a struct” Yes (well a typedef to a struct)

“then as a function and called from main”. No

“Is it fine?” Yes (but should be changed to ANSI syntax)

“how does it work?” Pretty good

“Is option_info inside the function calc_options?” It is the type of the 3rd argument options

“Because option_info seems using the parameters defined in calc_options.” It is the type of parameter options

“Or calc_options body is written somewhere else in any other file in the include section ?” Nope

2

solved function declaration in pro*C without body [closed]