wiki:GeneralTransformation

Version 1 (modified by zmanchun, 12 years ago) ( diff )

--

The General Transformation deals with common features of C programs. Currently, we only translate away the arguments of the main function.

For example,

... // declarations
int main(int argc, char *argv[]){
  ...//main body
}
...// other code

After General Transformation, the code becomes:

... // declarations

$input int __argc;
$input char __argv[][];

void main(){
  int argc = __argc;
  char** argv = (char**) $malloc(argc*sizeof(char*));

  for(int i = 0; i < argc; i++){
    argv[i] = &__argv[i][0];
  }

  ... // main body

  free(argv);
}
...// other code
Note: See TracWiki for help on using the wiki.