go away spammer

Author Topic: underscores in C?  (Read 2147 times)

0 Members and 1 Guest are viewing this topic.

Offline arixroboticsTopic starter

  • Full Member
  • ***
  • Posts: 119
  • Helpful? 3
    • TalasTronics WCIT KL2008 Fund Raising
underscores in C?
« on: October 08, 2008, 03:17:32 AM »
Hi all,

Why is there an underscore before the U1RXIF register name in the following code snippets?

Code: [Select]
_U1RXIF=0; // Clear UART RX Interrupt Flag

And why are there many more underscores in the method declaration below?

Code: [Select]
void __attribute__((interrupt, no_auto_psv)) _IC1Interrupt(void)
I have no idea what the undescores do. Can anyone explain?


Offline ArcMan

  • Supreme Robot
  • *****
  • Posts: 519
  • Helpful? 4
  • Mmmm... Plasma
Re: underscores in C?
« Reply #1 on: October 08, 2008, 05:15:54 PM »
Underscores preceding a variable name are, by convention, used for OS or programming package system calls.  Anyone can put as many underscores as they want wherever they want, it's just another character in the variable name.  But, like I said, convention.

Offline arixroboticsTopic starter

  • Full Member
  • ***
  • Posts: 119
  • Helpful? 3
    • TalasTronics WCIT KL2008 Fund Raising
Re: underscores in C?
« Reply #2 on: October 09, 2008, 12:15:03 AM »
But then why do they put an underscore before the word 'U1RXIF'? That word is a register name, which I dont think can be chaged by the programmer? And there was definately no declaration of a variable called '_U1RXIF' anywhere in the code.

This is for a dsPIC33FJ128MC802, and U1RXIF is the interrupt flag register of the UART's receiver, if these helps...


Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: underscores in C?
« Reply #3 on: October 14, 2008, 06:20:09 PM »
those register names are just macros defined somewhere else for the compiler.

 


Get Your Ad Here