[tad off topic] Check out Linux Journal

The next issue (Jan 01) of Linux Journal has articles on SDL and OpenAL and
other multimedia things.

Sorry if this is a tad off topic but I thought that it might be worth
posting.

Anyone have that tux.bmp from that article handy? They haven’t posted
article81 yet…

Mike

xDAVIDx wrote:>

The next issue (Jan 01) of Linux Journal has articles on SDL and OpenAL and
other multimedia things.

Sorry if this is a tad off topic but I thought that it might be worth
posting.

BTW - Is it proper c to put a semicolon after a “}” - ie - }; I’ve never
used the semicolon after that - it compiles and works fine - is this
just a programming style, or have I been goofing up all this time? This
is in reference to the SDL examples given in the LJ article.

Mike

Michael Vanecek wrote:>

Anyone have that tux.bmp from that article handy? They haven’t posted
article81 yet…

Mike

xDAVIDx wrote:

The next issue (Jan 01) of Linux Journal has articles on SDL and OpenAL and
other multimedia things.

Sorry if this is a tad off topic but I thought that it might be worth
posting.

BTW - Is it proper c to put a semicolon after a “}” - ie - };

I can’t answer with any claim of correctness (check the C Programming FAQ :slight_smile: ),
but this does remind me of a question I asked my professor when I first
starting learning C…

For multiline chunks, you need to use braces:

if (foo == bar)
{
multiple…
statements…
}

while (!done)
{
multiple…
statements…
}

int function(int arg)
{
multiple…
statements…
}

And for single-line things, you can do it this way, without braces:

if (foo == bar)
single_statement;

while (!done)
single_statement;

But you CANNOT do this!!!

int small_function(int arg)
return some_value;

You NEED braces for functions, even if they’re only one statement.

Feh! :slight_smile:

-bill!

BTW - Is it proper c to put a semicolon after a “}” - ie - };

No, the semicolon is not necessary, it’s essentially a noop in this case.

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

William Kendrick wrote:

But you CANNOT do this!!!

int small_function(int arg)
return some_value;

You NEED braces for functions, even if they’re only one statement.

Feh! :slight_smile:

How else will the compiler distinguish things like global variable declarations,
or function attributes?

In C++ it can get even more complex, what with being able to declare a member
function “const” (does the const keyword apply to function, or the line of code
following it?)> -bill!

Someone said:

William Kendrick wrote:

But you CANNOT do this!!!

int small_function(int arg)
return some_value;

You NEED braces for functions, even if they’re only one statement.

How else will the compiler distinguish things like global variable
declarations, or function attributes?

Huh? Since when can any part of:

int small_function(int arg)
return some_value;

be seen as a variable declaration!? :slight_smile:

-bill!

int small_function(int arg)
return some_value;

be seen as a variable declaration!? :slight_smile:

Please, take this off the list! :slight_smile:

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

BTW - Is it proper c to put a semicolon after a “}” - ie - }; I’ve never
used the semicolon after that - it compiles and works fine - is this
just a programming style, or have I been goofing up all this time? This
is in reference to the SDL examples given in the LJ article.

For C I think it’s optional.
For C++ it’s pretty much mandatory (or it used to be anyways)

G’day, eh? :slight_smile:
- TeunisOn Fri, 15 Dec 2000, Michael Vanecek wrote:

winterlion wrote:

BTW - Is it proper c to put a semicolon after a “}” - ie - }; I’ve never
used the semicolon after that - it compiles and works fine - is this
just a programming style, or have I been goofing up all this time? This
is in reference to the SDL examples given in the LJ article.

For C I think it’s optional.
For C++ it’s pretty much mandatory (or it used to be anyways)

Being an experienced C++ coder, I can assure you the only place a semi-colon
is required after an ending curly brace is at the end of
class/structure/union definition, which is the same as C (for structs and
unions, anyways, as C doesn’t have the class keyword).

Unless of course I’m forgetting something, which I wouldn’t be surprised by
at all… ~,^

Sean Etc.> On Fri, 15 Dec 2000, Michael Vanecek wrote:

G’day, eh? :slight_smile:
- Teunis

William Kendrick wrote:

Huh? Since when can any part of:

int small_function(int arg)
return some_value;

be seen as a variable declaration!? :slight_smile:

LOL. Well, that particular example would work fine. Something like:

class klass
{
public:
void small_function (int arg)
const static int = arg;
};

Would have problems though.

Ya, I know the code is pointless, but have you ever seen some of the
stuff people out there write? Especially what some of the 'professional’
C/C++ coders write - I’ve seen snippets of code that need to be shot and
buried. ~,^

Ah well.

Sean Etc.>

-bill!

Sam Lantinga wrote:

Please, take this off the list! :slight_smile:

Sorry…

Sean Etc.>

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Sean Etc. sed:

Ya, I know the code is pointless, but have you ever seen some of the
stuff people out there write? Especially what some of the 'professional’
C/C++ coders write - I’ve seen snippets of code that need to be shot and
buried. ~,^

No, but I’m sure the folks at Loki who are porting Win32 games have.

-bill!
(promising not to follow-up to this topic no more!)

winterlion wrote:

BTW - Is it proper c to put a semicolon after a “}” - ie - };
I’ve never used the semicolon after that - it compiles and
works fine - is this just a programming style, or have I been
goofing up all this time? This is in reference to the SDL
examples given in the LJ article.

For C I think it’s optional.
For C++ it’s pretty much mandatory (or it used to be anyways)

Being an experienced C++ coder, I can assure you the only place a
semi-colon is required after an ending curly brace is at the end of
class/structure/union definition, which is the same as C (for
structs and unions, anyways, as C doesn’t have the class keyword).

Unless of course I’m forgetting something, which I wouldn’t be
surprised by at all… ~,^

I could be wrong too, but I think you’re right.

Why? Well, C++ is meant to be a superset to C, in a way that allows
any C program to also be a C++ program. That is, the rules could no
have changed like that…

//David

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -'On Saturday 16 December 2000 05:46, Sean Middleditch wrote:

On Fri, 15 Dec 2000, Michael Vanecek wrote:

If you’ve tried writing a parser for a C-like language using yacc
(GNU bison would be the most common implementation on GNU/Linux
systems, I think) or similar, you’d see why. :wink:

Ok, i would be possible to do with some hacks, but it would
increase the chance of minor typos leading to totally
incomprehensible compile error messages. Not fun…

//David

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -'On Saturday 16 December 2000 00:57, William Kendrick wrote:

Someone said:

William Kendrick wrote:

But you CANNOT do this!!!

int small_function(int arg)
return some_value;

You NEED braces for functions, even if they’re only one
statement.

How else will the compiler distinguish things like global
variable declarations, or function attributes?

Huh? Since when can any part of:

int small_function(int arg)
return some_value;

be seen as a variable declaration!? :slight_smile: