View Single Post
Old 08-12-2012, 12:50 PM   #185
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Quote:
Originally Posted by knc1 View Post
gcc doesn't like 'exit' either, try: 'return 0'
Those errors were from the program posted above by NuPogodi when compiled with -static, which has "return 0". Apparently that calls an exit function. I changed it to include <stdio.h> instead of "stdio.h", and to print argc (and reformatted it).

Leaving out -static gets no errors, but creates a file that is not recognized as executable on the kindle, and hexdump shows that it references uclibc.

The tcc I got from lrizzo ALSO has those link problems with -static, so it may be unrelated to how it was built. Leaving out -static results in an executable program, but it gets a large negative argc value.

parmtest.c:
PHP Code:
#include <stdio.h>
#include <stdlib.h>

int main(int argcchar **argv) {
    
int i;
    
printf ("argc=%d\n"argc);
    
printf ("argv[0]=(%s)\n"argv[0]);
    for (
i=1;i<5;i++) printf("argv[%d]=(%s)\n",i,argv[i]);
    if (
argc<2printf("No args\n");
    return 
0;

Code:
[root@kindle tcc]# ./tcc-knc1 -E
tcc version 0.9.25 - Tiny C Compiler - Copyright (C) 2001-2006 Fabrice Bellard
Usage: tcc [options...] [-o outfile] [-c] infile(s)...
       tcc [options...] -run infile [arguments...]
General options:
  -v          display current version, increase verbosity
  -c          compile only - generate an object file
  -o outfile  set output filename
  -Bdir       set tcc internal library and include path
  -bench      output compilation statistics
  -run        run compiled source
  -fflag      set or reset (with 'no-' prefix) 'flag' (see man page)
  -Wwarning   set or reset (with 'no-' prefix) 'warning' (see man page)
  -w          disable all warnings
Preprocessor options:
  -E          preprocess only
  -Idir       add include path 'dir'
  -Dsym[=val] define 'sym' with value 'val'
  -Usym       undefine 'sym'
Linker options:
  -Ldir       add library path 'dir'
  -llib       link with dynamic or static library 'lib'
  -pthread    link with -lpthread and -D_REENTRANT (POSIX Linux)
  -shared     generate a shared library
  -soname     set name for shared library to be used at runtime
  -static     static linking
  -rdynamic   export all global symbols to dynamic linker
  -r          generate (relocatable) object file
Debugger options:
  -g          generate runtime debug info
  -bt N       show N callers in stack traces
Misc options:
  -MD         generate target dependencies for make
  -MF depfile put generated dependencies here
[root@kindle tcc]#
Code:
[root@kindle tcc]# ./tcc-lrizzo -E
tcc version 0.9.25 - Tiny C Compiler - Copyright (C) 2001-2006 Fabrice Bellard
usage: tcc [-v] [-c] [-o outfile] [-Bdir] [-bench] [-Idir] [-Dsym[=val]] [-Usym]
           [-Wwarn] [-g] [-b] [-bt N] [-Ldir] [-llib] [-shared] [-soname name]
           [-static] [infile1 infile2...] [-run infile args...]

General options:
  -v          display current version, increase verbosity
  -c          compile only - generate an object file
  -o outfile  set output filename
  -Bdir       set tcc internal library path
  -bench      output compilation statistics
  -run        run compiled source
  -fflag      set or reset (with 'no-' prefix) 'flag' (see man page)
  -Wwarning   set or reset (with 'no-' prefix) 'warning' (see man page)
  -w          disable all warnings
Preprocessor options:
  -E          preprocess only
  -Idir       add include path 'dir'
  -include f  #include file 'f' before everything else
  -Dsym[=val] define 'sym' with value 'val'
  -Usym       undefine 'sym'
  -M          generate include list. Implies -E
  -dM         generate macros list. Implies -E
  -MT file    use 'file' as target for -M.
Linker options:
  -Ldir       add library path 'dir'
  -llib       link with dynamic or static library 'lib'
  -shared     generate a shared library
  -soname     set name for shared library to be used at runtime
  -static     static linking
  -rdynamic   export all global symbols to dynamic linker
  -r          generate (relocatable) object file
Debugger options:
  -g          generate runtime debug info
  -bt N       show N callers in stack traces
Ignored options (for gcc compatibility):
  -std=X      
  -MD name
  -MP
  -isystem dir
[root@kindle tcc]#
I am curious why they output different usage, but the same version number. And lrizzo's build has more preprocessor options.

Last edited by geekmaster; 08-12-2012 at 01:15 PM.
geekmaster is offline   Reply With Quote