6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Sep 21, 2024 9:31 pm

All times are UTC




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Apr 13, 2016 4:59 pm 
Offline
User avatar

Joined: Tue Mar 15, 2016 4:06 pm
Posts: 35
I have been doing a lot of 6502 assembly programming. Last night I went back to doing some C programming and I needed to comment out some code. I commented it out, compiled, and to my surprise it was still running as before. I then spent a good 20 minutes trying to figure out why commented out code could still possibly run.

It turns out I used a semicolon in the C code for the comment instead of //. Prepending a line in C with a semicolon does not produce a compile error.

Anyone else mix this up?

_________________
My 6502 Game System: https://hackaday.io/project/9325-dodo-6502-homebrew-game-system


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 13, 2016 6:42 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Hee hee. It might be a bit like switching keyboards - sometimes I use a US style keymapping and sometimes a UK one. There's a moment of adjustment as the punctuation comes out wrong, and then the fingers and the brain adust themselves.


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 13, 2016 7:40 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8390
Location: Midwestern USA
pnoyes wrote:
I have been doing a lot of 6502 assembly programming. Last night I went back to doing some C programming and I needed to comment out some code. I commented it out, compiled, and to my surprise it was still running as before. I then spent a good 20 minutes trying to figure out why commented out code could still possibly run.

It turns out I used a semicolon in the C code for the comment instead of //. Prepending a line in C with a semicolon does not produce a compile error.

Anyone else mix this up?

Interesting that the compiler didn't issue a diagnostic with the semicolon at the start of the line. Which compiler is this?

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 13, 2016 7:44 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8390
Location: Midwestern USA
BigEd wrote:
Hee hee. It might be a bit like switching keyboards - sometimes I use a US style keymapping and sometimes a UK one. There's a moment of adjustment as the punctuation comes out wrong, and then the fingers and the brain adust themselves.

That used to happen to me back in the days of programming Commodore computers. I'd be on a C-128 for a while and then switch over to a PC. Most of the QWERTY keys were the same, but punctuation and other symbols were in different locations. In particular, a colon on a C-128 keyboard is an unSHIFTed character, but is a SHIFTed character on a standard PC keyboard (as well as on an ASCII terminal keyboard). That caused me no end of grief. :evil:

Incidentally, it is C that is causing brain pollution, not assembly language. :D

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 13, 2016 7:50 pm 
Offline

Joined: Thu Mar 03, 2011 5:56 pm
Posts: 284
BigDumbDinosaur wrote:
pnoyes wrote:
I have been doing a lot of 6502 assembly programming. Last night I went back to doing some C programming and I needed to comment out some code. I commented it out, compiled, and to my surprise it was still running as before. I then spent a good 20 minutes trying to figure out why commented out code could still possibly run.

It turns out I used a semicolon in the C code for the comment instead of //. Prepending a line in C with a semicolon does not produce a compile error.

Anyone else mix this up?

Interesting that the compiler didn't issue a diagnostic with the semicolon at the start of the line. Which compiler is this?


Why should a C compiler complain about a semicolon at the start of a line? Keep in mind that the canonical string copy routine in C is something like
Code:
void strcpy(char *d, char *s) {
 while (*d++ = *s++)
    ;
}


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 14, 2016 6:40 am 
Offline

Joined: Sat Mar 27, 2010 7:50 pm
Posts: 149
Location: Chexbres, VD, Switzerland
pnoyes wrote:
I have been doing a lot of 6502 assembly programming. Last night I went back to doing some C programming and I needed to comment out some code. I commented it out, compiled, and to my surprise it was still running as before. I then spent a good 20 minutes trying to figure out why commented out code could still possibly run.

It turns out I used a semicolon in the C code for the comment instead of //. Prepending a line in C with a semicolon does not produce a compile error.

Anyone else mix this up?

Don't you use syntax colouring? Pretty much every editor uses them nowadays.


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 14, 2016 8:12 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
(Personally I never liked colour in my editor. I suppose like a lot of things it's a matter of personal preference.)


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 14, 2016 8:24 am 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8510
Location: Southern California
Same here. I don't use or like the color.

Quote:
Incidentally, it is C that is causing brain pollution, not assembly language. :D

+1

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 14, 2016 8:34 am 
Offline

Joined: Sat Mar 27, 2010 7:50 pm
Posts: 149
Location: Chexbres, VD, Switzerland
I do no see any advantage of NOT using syntax colouring. Using them avoids very stupid errors like that. I also use it when coding in assembly.

Quote:
Incidentally, it is C that is causing brain pollution, not assembly language. :D

+2 :)


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 14, 2016 8:57 am 
Offline

Joined: Sun Apr 10, 2011 8:29 am
Posts: 597
Location: Norway/Japan
I dislike colours in terminal windows (b/c they always clash with the background I use), but I use colours in the editor. But obviously I use my own setup for the colours, not the default one. For that, it works very well.
As for C.. well, compared to those sqrt-solving Basic programs posted here a while ago, C is light years cleaner! :)


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 14, 2016 5:22 pm 
Offline
User avatar

Joined: Tue Mar 15, 2016 4:06 pm
Posts: 35
Bregalad wrote:
pnoyes wrote:
I have been doing a lot of 6502 assembly programming. Last night I went back to doing some C programming and I needed to comment out some code. I commented it out, compiled, and to my surprise it was still running as before. I then spent a good 20 minutes trying to figure out why commented out code could still possibly run.

It turns out I used a semicolon in the C code for the comment instead of //. Prepending a line in C with a semicolon does not produce a compile error.

Anyone else mix this up?

Don't you use syntax colouring? Pretty much every editor uses them nowadays.


I do use syntax highlighting. I don't know why I didn't recognize that the lines of code didn't gray out. Perhaps because there were no other comments in the vicinity.

_________________
My 6502 Game System: https://hackaday.io/project/9325-dodo-6502-homebrew-game-system


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 14, 2016 7:30 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8390
Location: Midwestern USA
rwiker wrote:
BigDumbDinosaur wrote:
pnoyes wrote:
I have been doing a lot of 6502 assembly programming. Last night I went back to doing some C programming and I needed to comment out some code. I commented it out, compiled, and to my surprise it was still running as before. I then spent a good 20 minutes trying to figure out why commented out code could still possibly run.

It turns out I used a semicolon in the C code for the comment instead of //. Prepending a line in C with a semicolon does not produce a compile error.

Anyone else mix this up?

Interesting that the compiler didn't issue a diagnostic with the semicolon at the start of the line. Which compiler is this?

Why should a C compiler complain about a semicolon at the start of a line? Keep in mind that the canonical string copy routine in C is something like
Code:
void strcpy(char *d, char *s) {
 while (*d++ = *s++)
    ;
}

The semicolon in the middle of the strcpy while loop works because it is on an otherwise blank line, which automatically makes it the terminating character.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Last edited by BigDumbDinosaur on Thu Apr 14, 2016 7:45 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 14, 2016 7:43 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8390
Location: Midwestern USA
BigEd wrote:
(Personally I never liked colour in my editor. I suppose like a lot of things it's a matter of personal preference.)

I use a limited amount of color, the color choices being ones that stay out of where my vision messes up. Some color combinations, such as blue with green, are hard for me to read. Even worse are colors on top of a white back ground. :( The below image is about as colorful as I get.
Attachment:
editorscreen.jpg
editorscreen.jpg [ 394.76 KiB | Viewed 1342 times ]

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 14, 2016 9:24 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
I like more constant contrast than that - for me, the green looks good but the red is too dark. Of course this is very much in the area of personal preference.

For the C question, C allows null statements, which may help explain why there's no error in mistakenly trying to comment out a block with semicolons.


Top
 Profile  
Reply with quote  
PostPosted: Thu Apr 14, 2016 9:34 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8390
Location: Midwestern USA
BigEd wrote:
I like more constant contrast than that - for me, the green looks good but the red is too dark. Of course this is very much in the area of personal preference.

My office is not brightly lit unless I turn on the overhead lights, so I generally don't use high screen intensity levels. Also, the low end of the visible light spectrum looks brighter to me than the upper end, so I dial down red to some extent. However, the red in the JPEG I posted is darker than in actuality.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: