I would like to use both the InnoIDE and ISCC/ISPP, the difference being that I would like to pass in a parameter, which will override a #define in the script.
In the command line I can pass /Dmyarg=myvalue. That is the same as #define myarg myvalue in the script.
Sadly, the script takes precedence over the command line value. I know, as I tried. I can obviously comment out the #define in the script and the command line define will work, however then I will not be able to use the IDE to build.
Is it possible to set a #define inside InnoIDE somewhere for the project or is there some means to have the command line #define take precedence?
In your script, do something like this:
#ifndef myarg
# define myarg "mydefault"
#endif
Now, if you compile in the IDE or if you use the command line without specifying /Dmyarg="something", then it will use the default specified in the script. Otherwise, if you do specify something on the command line then it will use that instead.
Related
Is there a way to run multiple C program through one single C source code file using command line argument?
E.g. suppose the executable file is named, testing.out, if in the runtime one wants
the first test, then type “Testing.out 1”, if the second, “Testing.out 2”,
etc.
Yes, this can be easily done using the command line arguments functionality provided by C.
You can read more about it here: https://www.tutorialspoint.com/cprogramming/c_command_line_arguments.htm
And a lots of other tutorials:
https://www.geeksforgeeks.org/command-line-arguments-in-c-cpp/
https://www.cprogramming.com/tutorial/c/lesson14.html
I'm trying to use //go:generate to run an external tool before compiling my code, and as I need to pass a certain number of parameters, the line becomes rather long.
It seems that there is no way to write a multiline go:generate command, is it correct? Are there alternative approaches?
Thanks
There is no way to split go generate command into several lines, but there are some tips.
If you need to run multiple short commands you can write them one by one like the following.
//go:generate echo command A
//go:generate echo command B
//go:generate ls
You also should know that there is not a bash script but a raw command. So the following works not as one may expect.
//go:generate echo something | tr a-z A-Z > into_file
// result in "something | tr a-z A-Z > into_file"
For long or complex commands you should use separate script (or maybe go program) that is called from go:generate comment.
//go:generate sh generate.sh
//go:generate go run generator.go arg-A arg-B
In generator.go you should use build tag to prevent it from normal compilation with other files.
// +build ignore
package main
// ...
The best place to learn go is go sources: https://github.com/golang/go/blob/master/src/runtime/runtime.go#L13
This is far from an ideal solution, but you could use a directive of the form
//go:generate -command <alias> <command-with-parameters>
The directive above specifies, for the remainder of the current source file only, that <alias> is equivalent to the command <command-with-parameters>.
This method might be useful in your case since you mentioned that you needed to pass a certain number of parameters (I'm assuming lots). You could potentially use it to emulate a single line break. I say single because nested aliases don't work (at least right now).
An example:
//go:generate BAKE "ramen"
// The above go:generate directive does NOT work, unless:
// - You somehow have bake on your path.
// - You did a `//go:generate -command BAKE ...`
/* Now, assuming you have a command `kitchen-tools` with lots of possible parameters... */
//go:generate -command BAKE kitchen-tools -appliance=sun -temp=5800K -time=1ns
//go:generate BAKE -panic=if-burnt -safety=fire_extinguisher,mitts "fresh pizza"
// The previous //go:generate line runs the following command:
// kitchen-tools -appliance=sun -temp=5800K -time=1ns -panic=always -safety=fire_extinguisher,mitts "fresh pizza"
/* BAKE can be used as many times as necessary for the rest of the file. For instance... */
//go:generate BAKE -no-return -unsafe "grand piano"
Furthermore, I suggest you use the build tag generate (rather than something like ignore) since the go generate tool sets the build tag generate when it examines your files:
// +build generate
package main
// ...
For instance, I saw the following line in ATSLIB:
#define ATS_PACKNAME "ATSLIB.libats.deqarray"
What is the meaning of this line? What purpose does it serve?
Say you declare a function in a file XYZ.dats:
extern fun foo (...): ...
The ATS compiler generates a global name for foo using the full path
of XYZ.dats, which is often hard to read.
If the flag ATS_PACKNAME is set, then the global name for foo is
${ATS_PACKNAME}foo, where ${ATS_PACKNAME} is the string value of
ATS_PACKNAME.
http://discourse.ats-lang.org/t/ats-packname/645/2
I've set the command line args for my app in the project properties -> debugging -> command arguments section.
If I run the program from command line directly I do:
progname arg1 arg2
So I've set the command line arguments in VS to
arg1 arg2,
as described here.
But, the program doesn't seem to run the same way as in running it from command line. The arguments are text files, and in the command line it can load those text files correctly, in VS2010 it doesn't somehow. Any ideas why?
Edit: update/clarification of post:
I am not getting any exceptions.
I may have oversimplified the problem too much in my explanation. I'm not actually loading text files, I'm loading a physics engine, which should be determined at runtime, so I need command line arguments.
The code used for loading the physics engine, on a high level, is:
if ( argc > 2 )
{
#ifndef PAL_STATIC
PF->LoadPALfromDLL();
#endif
//DebugBreak(); // for debugging ;)
PF->SelectEngine(argv[1]);
if (!pp) {
#ifdef _WIN32
MessageBox(NULL,L"Could not start physics!",L"Error",MB_OK);
/* ^ This is the error I am getting, i.e. pp is NULL,
so "PF->SelectEngine(argv[1]);" is not loading engine correctly */
#else
printf("Could not start physics engine %s!\n",argv[1]);
#endif
return -1;
}
I am using Bullet, which is run like this:
progname.exe arg1 arg2,
arg1 is the physics engine name and arg2 is a physics file to load, but it hangs on arg1.
The specific way I invoke this on the command line is:
progname.exe Bullet filename.
If i do this on command line it works, but if I pass these arguments to the debugger, I get a problem saying could not load physics engine.
This may be a result of the internals of the physics engine loader, which is from another source, but my guess is that this should work the same way whether I pass these arguments in the command line or in the debugger settings of VS.
I will look into the UAC settings and see what they say.
As it says in : https://msdn.microsoft.com/en-us/library/17w5ykft.aspx, you can try adding a backslash to every "\" character, to escape them inside the path. For example :
Before : "C:\somewhere\someplace\physics_engine"
After : "C:\\somewhere\\someplace\\physics_engine"
My problem lies with my confusion with shell variables.
To my understanding, variables allow me to store a value (String in this case) and to call it later in my code. So if I wanted to have a variable that holds the path to some set of scripts, I could ideally just store it like this:
SPTH = '/home/Foo/Documents/Programs/ShellScripts/Butler'
//Later on in the script//
cd $SPTH
./script1
What I'm trying to do, with probably the wrong syntax, is to set the path to variable SPTH.
Then I use cd with argument $SPTH.
Ideally this would allow me to run the file there without typing in the path. However it doesn't work. The $SPTH is ignored and the result is as if cd was used alone.
So what am I doing wrong? And what would be a way to do this?
Don't use spaces...
(Incorrect)
SPTH = '/home/Foo/Documents/Programs/ShellScripts/Butler'
(Correct)
SPTH='/home/Foo/Documents/Programs/ShellScripts/Butler'
To add to the above correct answer :-
For my case in shell, this code worked (working on sqoop)
ROOT_PATH="path/to/the/folder"
--options-file $ROOT_PATH/query.txt