History

Warn about a conflicting compile options spectified on the command line. Try "tcc -E -c tccasm.c -o tccasm.o"

seyko committed 11 years ago

Commit c334b591 parent b93179f3 files · +19 −7Browse files

Unified · Split

3 files
  1. libtcc.c +11 −1
  2. libtcc.h +5 −5
  3. tcc.c +3 −1
libtcc.c+11−1
@@ -906,7 +906,7 @@ LIBTCCAPI TCCState *tcc_new(void) · 905 unmodified lines
906906 #else
907907 tcc_set_lib_path(s, CONFIG_TCCDIR);
908908 #endif
909− s->output_type = TCC_OUTPUT_MEMORY;
909+ s->output_type = 0;
910910 preprocess_new();
911911 s->include_stack_ptr = s->include_stack;
912912
@@ -1831,6 +1831,8 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 918 unmodified lines
18311831 s->do_debug = 1;
18321832 break;
18331833 case TCC_OPTION_c:
1834+ if (s->output_type)
1835+ tcc_warning("-c: some compiler action already specified (%d)", s->output_type);
18341836 s->output_type = TCC_OUTPUT_OBJ;
18351837 break;
18361838 #ifdef TCC_TARGET_ARM
@@ -1849,6 +1851,8 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 12 unmodified lines
18491851 s->static_link = 1;
18501852 break;
18511853 case TCC_OPTION_shared:
1854+ if (s->output_type)
1855+ tcc_warning("-shared: some compiler action already specified (%d)", s->output_type);
18521856 s->output_type = TCC_OUTPUT_DLL;
18531857 break;
18541858 case TCC_OPTION_soname:
@@ -1862,6 +1866,8 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 7 unmodified lines
18621866 break;
18631867 case TCC_OPTION_r:
18641868 /* generate a .o merging several output files */
1869+ if (s->output_type)
1870+ tcc_warning("-r: some compiler action already specified (%d)", s->output_type);
18651871 s->option_r = 1;
18661872 s->output_type = TCC_OUTPUT_OBJ;
18671873 break;
@@ -1878,6 +1884,8 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 10 unmodified lines
18781884 s->print_search_dirs = 1;
18791885 break;
18801886 case TCC_OPTION_run:
1887+ if (s->output_type)
1888+ tcc_warning("-run: some compiler action already specified (%d)", s->output_type);
18811889 s->output_type = TCC_OUTPUT_MEMORY;
18821890 tcc_set_options(s, optarg);
18831891 run = 1;
@@ -1907,6 +1915,8 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 23 unmodified lines
19071915 cstr_ccat(&linker_arg, '\0');
19081916 break;
19091917 case TCC_OPTION_E:
1918+ if (s->output_type)
1919+ tcc_warning("-E: some compiler action already specified (%d)", s->output_type);
19101920 s->output_type = TCC_OUTPUT_PREPROCESS;
19111921 break;
19121922 case TCC_OPTION_MD:
libtcc.h+5−5
@@ -58,11 +58,11 @@ LIBTCCAPI int tcc_compile_string(TCCState *s, const char *buf); · 57 unmodified lines
5858
5959 /* set output type. MUST BE CALLED before any compilation */
6060 LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type);
61−#define TCC_OUTPUT_MEMORY 0 /* output will be run in memory (default) */
62−#define TCC_OUTPUT_EXE 1 /* executable file */
63−#define TCC_OUTPUT_DLL 2 /* dynamic library */
64−#define TCC_OUTPUT_OBJ 3 /* object file */
65−#define TCC_OUTPUT_PREPROCESS 4 /* only preprocess (used internally) */
61+#define TCC_OUTPUT_MEMORY 1 /* output will be run in memory (default) */
62+#define TCC_OUTPUT_EXE 2 /* executable file */
63+#define TCC_OUTPUT_DLL 3 /* dynamic library */
64+#define TCC_OUTPUT_OBJ 4 /* object file */
65+#define TCC_OUTPUT_PREPROCESS 5 /* only preprocess (used internally) */
6666
6767 /* equivalent to -Lpath option */
6868 LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname);
tcc.c+3−1
@@ -249,7 +249,6 @@ int main(int argc, char **argv) · 248 unmodified lines
249249 const char *first_file = NULL;
250250
251251 s = tcc_new();
252− s->output_type = TCC_OUTPUT_EXE;
253252
254253 optind = tcc_parse_args(s, argc - 1, argv + 1);
255254 tcc_set_environment(s);
@@ -259,6 +258,9 @@ int main(int argc, char **argv) · 3 unmodified lines
259258 return 1;
260259 }
261260
261+ if (s->output_type == 0)
262+ s->output_type = TCC_OUTPUT_EXE;
263+
262264 if (s->option_m)
263265 exec_other_tcc(s, argv, s->option_m);
264266

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t