This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Function parameter

Hi All,
I am newbie in this. Is this function declaration right, as it has bit as parameter,
void myfunc(unsigned char,bit);

Ashutosh

Parents
  • No, the compiler will not detect if it's right or not - ie, if it does what the programmer intended - the compiler will just determine whether it is valid syntax or not.

    The classic example is, of course:

    // Test if 'a' is equal to 'b'
    if( a = b )
    {
       // The test is valid syntax, but does not match the
       // programmer's intention stated in the comment!
    }
    

    Yes, this is such a common mistake that many (most?) compilers today will warn about it - but compilers cannot possibly recognise every mis-application of correct syntax!

Reply
  • No, the compiler will not detect if it's right or not - ie, if it does what the programmer intended - the compiler will just determine whether it is valid syntax or not.

    The classic example is, of course:

    // Test if 'a' is equal to 'b'
    if( a = b )
    {
       // The test is valid syntax, but does not match the
       // programmer's intention stated in the comment!
    }
    

    Yes, this is such a common mistake that many (most?) compilers today will warn about it - but compilers cannot possibly recognise every mis-application of correct syntax!

Children