1. [OT] Speaking of C...

I'm not a professional developer, but I found this C quiz interesting. There are a couple of gotchas in there.

new topic     » topic index » view message » categorize

2. Re: [OT] Speaking of C...

Another interesting link: http://gcc.godbolt.org/

This is an interactive C compiler with a variety of asm targets. The filter options are amazing! This tool could save a lot of time when you have a problem piece of code.

It would be pretty handy if we had a tool like this for interactively compiling Euphoria to IL or to C.

new topic     » goto parent     » topic index » view message » categorize

3. Re: [OT] Speaking of C...

I don't know what I'm doing wrong. I typed in the following:

    1. int c;
      c = 0; ## and after the second line I got an error saying "C++ requires a type specifier for all declarations".

Any idea what I'm doing wrong?

new topic     » goto parent     » topic index » view message » categorize

4. Re: [OT] Speaking of C...

Lnettnay said...

I don't know what I'm doing wrong. I typed in the following:

int c;\\ 
c = 0; 
and after the second line I got an error saying "C++ requires a type specifier for all declarations".

Any idea what I'm doing wrong?

Is that the entire file? You can't have executable statements at top level like in Euphoria. You can make some assignments, like:

int c = 0; 

Can you tell us more what you're trying to do?

Matt

new topic     » goto parent     » topic index » view message » categorize

5. Re: [OT] Speaking of C...

Okay, now something is really squirrelly. On my last post this is what was in the edit box:

I don't know what I'm doing wrong. I typed in the following:\\ 
## 
int c;\\ 
c = 0; 
## 
and after the second line I got an error saying "C~++ requires a type specifier for all declarations". 

And this is what the preview looked like:

I don't know what I'm doing wrong. I typed in the following: 
int c; 
c = 0; 
 
and after the second line I got an error saying "C++ requires a type specifier for all declarations". 

But now, when Matt quotes it some of the formatting is different. ?!?

new topic     » goto parent     » topic index » view message » categorize

6. Re: [OT] Speaking of C...

Just pucking around. Not really trying to do anything. Just trying to see what it does.

new topic     » goto parent     » topic index » view message » categorize

7. Re: [OT] Speaking of C...

Wrap it in a function like main().

int main(void) { 
int c; 
c = 0; 
 
return c; 
} 
 

I also found that you want to make sure to change or delete the compiler options field when trying different targets -- at first I thought that some of them weren't working but it was because the specific targets didn't understand the "-march=native" switch.

Edit: As I've been messing with C files doing experiments, I keep running into pitfalls like C has no top-level statements and that printf() does not take '1' as its first argument!

new topic     » goto parent     » topic index » view message » categorize

8. Re: [OT] Speaking of C...

Lnettnay said...

But now, when Matt quotes it some of the formatting is different. ?!?

I like to reformat quotes when I quote them. I also like to reformat posts that can benefit greatly from a well placed eucode tag or triple braces.

Matt

new topic     » goto parent     » topic index » view message » categorize

9. Formatting options

So the ##code text## actually means monospaced text. Does it have to be bracketed by the ##'s? And does it all have to be strung together without returns/line feeds?

new topic     » goto parent     » topic index » view message » categorize

10. Re: Formatting options

Lnettnay said...

So the ##code text## actually means monospaced text. Does it have to be bracketed by the ##'s? And does it all have to be strung together without returns/line feeds?

Actually you want to use {{{ at the beginning of a line all by itself, and close with }}} on its own line.

See CreoleHelp. See also http://wikicreole.org/wiki/CheatSheet.

Edit: Also, while <eucode></eucode> tags are designed for Euphoria, other languages like C are close enough that it still colors them rather nicely.

Edit 2: Try "reply with quote" on a few messages to see how they are written.

new topic     » goto parent     » topic index » view message » categorize

11. Re: Formatting options

Lnettnay said...

So the ##code text## actually means monospaced text. Does it have to be bracketed by the ##'s? And does it all have to be strung together without returns/line feeds?

You can

put stuff on multiple lines, and it's like any other bit of creole text.

    1. #

But if you add whitespace after the opening number signs, it gets interpreted as a numbered list. If you're going to post code, I suggest using eucode tags. It will syntax highlight for euphoria. You might prefer to post stuff in other languages inside the triple braces. They are the equivalent of pre html tags. I tend to use them for console output.

Matt

new topic     » goto parent     » topic index » view message » categorize

12. Re: [OT] Speaking of C...

Wrapping it gets it to work. Thank you.

The optimization that it does with -O2 just does the calculations and returns the result. I found out that if you don't initialize your variables it just returns with no value. Bet that would be fun to debug.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu