Hi.
The Compiler does not complain or show any error mistyping when typing
Expander_Write_PortB,(0,16); <---- extra comma after PortB
The function is not working with the comma.
//P
Just for info Expander Function
-
- Posts: 619
- Joined: 05 Jul 2008 06:05
- Location: Thailand
The old compiler doesn't catch it either. I think you have to remember that the compiler can help with syntax but the main responsibility is with the programmer to get it right (and that's the same with any programming language).
There are so many instances where comma seperation is legal, it would be very difficult for the compiler to weed out the illegal ones.
There are so many instances where comma seperation is legal, it would be very difficult for the compiler to weed out the illegal ones.
Re: Just for info Expander Function
Hi,
goes to:
This is the same as:
Now, it should be clear why this translates with no errors and results in no code generated for specified code line.
Ptech wrote:Hi.
The Compiler does not complain or show any error mistyping when typing
Expander_Write_PortB,(0,16); <---- extra comma after PortB
The function is not working with the comma.
//P
So,mikroC for dsPIC help wrote: One of the specifics of C is that it allows using of comma as a sequence operator to form so-called comma expressions or sequences. Comma expression is a comma-delimited list of expressions – it is formally treated as a single expression so it can be used in places where an expression is expected. The following sequence:results in the left-to-right evaluation of each expression, with the value and type of expression_2 giving the result of the whole expression. Result of expression_1 is discarded.Code: Select all
expression_1, expression_2;
Code: Select all
Expander_Write_PortB,(0,16);
Code: Select all
Expander_Write_PortB, // expression #1, legal, Expander_Write_PortB represent pointer to a function
( // denotes start of expression #2
0, // expression #3, legal, constant expression
16 // expression #4, legal, constant expression
) // denotes end of expression #2
;
Code: Select all
Expander_Write_PortB;
0;
16;