Macros

Pages: 12
So I wrote a preprocessor a little more complex than C's. I suck at writing tutorials, so I'd like my fellow programmers to review it and tell me if it's understandable. It should only take about ten minutes. There's also a couple examples, so you can verify that you understood everything right.

http://www.fileden.com/files/2008/6/22/1971683/macros.7z

What I didn't include is the preprocessor, since it's part of a larger system and there's a lot of libraries involved.
1.)
Good, simple example.
Typo, at one point you put
an related 10
instead of unrelated.

2.)
This is because it can't be guaranteed that the syntax used in the script to make macro call wasn't accidentally used by the script writer.
Sounds kind of odd...maybe something like
This is because the script could have made a "macro call" when it was not intended.
?
Typo,
convension
should be
convention
.
At the very end
It may be useful to put this in a macro of its own to avoid typing it every type
type should be time.
Other then that, good.

3.)
If you know how C macros work, you may notice that there behave differently.
There should be these I think.

4-End)
Good.
Alright, I fixed the typos.

1.)
Good, simple example.
Do you mean I should use one, or that I am using one?
That you are using one. Simple examples are good.
I'd very much like to play around with your preprocessor. Can I have a download link or something? I hope gZip can unzip .7z files...

Edit: Nope.

Wine + winrar? Ok that worked.
Last edited on
Heh heh. I just realized I left my debug.bat in the .7z.

There's a 7-zip command line tool for Linux called 7z.
7-zip is a pretty rare case of an OS program written only for Windows. Another notable (and annoying) example is Notepad++.
Last edited on
That's a shame, I like Notepad++. I prefer gEdit though.

But as I'm a real man I use ed :P

So you did. It's not usually good to run everything as root :P

What does %* do?
Last edited on
I think it is all the arguments you passed to the batch file.

Oh and this: http://xkcd.com/378/
Last edited on
So you did. It's not usually good to run everything as root
I doesnt afraid of anything etc.

%* passes to the program all the arguments passed to the batch.

EDIT: Real programmers don't program. They will the universe into a desired state.
Last edited on
Oh, ok. I'll try willing the universe into a desired state in future.

"Be a really good 3D Game, be a really good 3D game..."
chrisname: I wanted to send you a PM but you don't accept them, so I'll just have to post it here.
If you still want to play with the preprocessor, go here: https://sourceforge.net/projects/onslaught-vn/files/
You can preprocess the examples in the doc/ directory by calling ./ONSlaught -pp-then-quit
I'm not sure, but this may or may not create a directory called ~/.ONSlaught/
It shouldn't, ./myProgram usually executes myProgram or whatever.

I'd accept PMs but I don't know how to. I haven't really bothered playing around with the account settings yet.
The program creates the directory to store its data files. I don't remember if -pp-then-quit makes it quit before or after doing this.
Oh, /. Sorry, I read it wrong.
I'm doing that alot lately :l

Oh and can I ask why you 7zipped the Linux file when Linux users can't open .7z files, unless they install WinRAR or 7zip or some other program that can open .7z and then run it with WINE?

Also, I'm getting the following error when trying to run the file in the bin directory:
1
2
3
4
$ ls
ONSlaught
$ ./ONSlaught
bash: ./ONSlaught: Permission denied
do you know why that might be?
Last edited on
why you 7zipped the Linux file
Because LZMA is stronger and than both bz2 and gzip.

Linux users can't open .7z files, unless they install WinRAR or 7zip or some other program that can open .7z and then run it with WINE?
Not true. Like I said before, 7z is available on both Linux and Windows.

It's possible it doesn't have execution permissions.
chmod +x ONSlaught
Last edited on
No, that didn't work. But as the source is right there in the same ftp directory, I'll try building it from source.
@echo off
"f:\Documents and Settings\root\My Documents\Visual Studio 2008\Projects\ONSlaught\Debug\ONSlaught.exe" %*

hehehheheee
chmod 777 ONSlaught might work. It worked for all the shell scripts I wrote... I'll try again later.

Edit:
I'm installing LinuxMint through windows at the moment so I'll try it either on Mint or Ubuntu later.

I also hate the restriction on the amount of primary partitions I can have. I can only install 3 operating systems :(
Stupid OEM. I deleted their recovery partition (then spent 3 hours with a recovery CD because the Ubuntu installer (I was reinstalling it to fix something to do with the /usr/bin directory) corrupted the windows partition) so I could use FreeBSD but I can't be asked to install FreeBSD now. Originally, in fact, I was going to try to install OSX on there but after I decided my money would be better spent buying a new PC (so I don't corrupt the NTFS partitions (I won't use windows on my new PC) and have to spend 3 hours recovering them) than an OS I'd probably use once and then get sick of. Plus that would risk killing my hard disk and various other hardwares, and I'd risk getting arrested by "The Man" (Apple)...
Last edited on
Well, that was pretty off-topic. Doesn't that belong on the OSX thread?

Linux and probably BSD can from a logical partitions, of which you can have up to 99, I believe.

risk getting arrested
The odds aren't against you.
Well I wanted to mention the chmod thing and then got into this whole speel about partitions.
Logical partitions I'm not sure about, but I know I can only have 4 primary partitions. But that's ok... The thing is I like to use the windows partitioner (it's damn simple but pretty quick so I use it... gparted is more complex) and it doesn't necessarily allow you to make everything you want...
Pages: 12