1.

Solve : cant compline the program using batch file?

Answer»

hi friends,
i tried to make a command string using BATCH file to run a C program. but i am not getting  wht exactly i do need.

the batch file(say tcrun.bat) is as below

echo off
cd c:\tc\bin
tcc -Lc:\tc\lib -Ic:\tc\include


and wrote this at command line to compile file.C
tcrun.bat file.c

but i got the error   
Error: No file name is given

someone please nail  the mistake out I am doing.

regards
sanThis is a mess

Code: [Select]cd c:\tc\bin
tcc -Lc:\tc\lib -Ic:\tc\include
You are passing a command line argument that is not referenced in your batch file:

Code: [Select]echo off
cd c:\tc\bin
tcc %1

The -L and -I switches are only needed when pointing to non-default directories.

Good luck.  thanks dude!!!
could you please elaborate more why it was  not working along with -I -L options?
and what does it mean by %l?

regards
sanThe -I and -L switches had nothing to do with your script not working. There was no reference to the passed argument (file.c). By using the command line reference (%1) in your script, the variable %1 will get replaced by whatever is passed as the first argument on the command line (file.c) in your case.

Also your script used the -I and -L switches. The directories you pointed to are the defaults and will get searched automatically. No harm in using them, just less typing (read: less chance of error).

Code: [Select]echo off
cd c:\tc\bin
tcc -Lc:\tc\lib -Ic:\tc\include %1

You can play around with the parameters. %1 might go before the switches.

Good luck. I appreciate you
thanks  a lot

by the way....if we use tcc file.c directly then what the matter?
is this a problem with batch file only?
and what if we want to pass second argument? Quote

by the way....if we use tcc file.c directly then what the matter?

For this to work the tcc program needs to be in the current directory or on the path.

It might be wise to use a path to the compiler and run your batch from the same directory where the SOURCE is located. This way you won't be tied to the directory where the compiler lives. The compiler will automatically search the lib and include directories, so unless you have header files or defs in other directories there is no need to use the switches.

Code: [Select]echo off
c:\tc\bin\tcc  %1

For a second PARAMETER you can use the reference %2 in your batch file. The Tiny C Compiler uses mostly switches, what do plan on passing as the second parameter?

Happy coding. 

Quote from: Sidewinder on July 01, 2008, 11:31:42 AM

For a second parameter you can use the reference %2 in your batch file. The Tiny C Compiler uses mostly switches, what do plan on passing as the second parameter?


'cause i want to make a batch file that shut down my system after a desired duration.

i used this shutdown.bat

Code: [Select] echo off
 shutdown -s -f -m [computer name] %1 %2

and used following command

shutdown.bat -t "120"

but this make system restart(not shutdown) immediately.
 
beside, if i use the following then i get error.

Code: [Select] echo off
 shutdown -s -f -m [computer name] -t %1

shutdown.bat "120"


please someone check this out and solve the problem Quote from: san_crazy on July 03, 2008, 11:27:24 AM
please someone check this out and solve the problem

And fix global warming and cure poverty and get me a pay rise.

san_crazy, wait your turn!
Quote from: Dias de verano on July 03, 2008, 11:35:28 AM
And fix global warming and cure poverty and get me a pay rise.

san_crazy, wait your turn!


i think you are the right person who can fix this problem, aren't u? Quote
And fix global warming and cure poverty and get me a pay rise.

If only.

san_crazy, does this have anything to do with the compiler script earlier in this thread. You asked about a second parameter, and now you've gone off and changed the topic. In the future it might be better for everybody's sanity if you started a NEW thread when you change topics.

You don't need the -m switch unless you're shutting down a remote machine on the network.

Code: [Select]shutdown -t %1 -f  -s

Run from the command prompt as batchfilename 120

Do not name your batch file shutdown, otherwise you'll run the MS command instead of your batch file.

 

Quote from: Sidewinder on July 03, 2008, 11:51:42 AM

Do not name your batch file shutdown, otherwise you'll run the MS command instead of your batch file.

 


Nice catch, SW. (Are you named after the snake or the missile?)
Quote from: Sidewinder on July 03, 2008, 11:51:42 AM

san_crazy, does this have anything to do with the compiler script earlier in this thread. You asked about a second parameter, and now you've gone off and changed the topic. In the future it might be better for everybody's sanity if you started a new thread when you change topics.

I'm sorry, I'll not repeat it again

Quote

You don't need the -m switch unless you're shutting down a remote machine on the network.

Code: [Select]shutdown -t %1 -f  -s

Run from the command prompt as batchfilename 120

Do not name your batch file shutdown, otherwise you'll run the MS command instead of your batch file.

 



thanks anyway


Discussion

No Comment Found