Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

passing a hex number to a function

Tags:

c

gcc 4.4.2 c89

I have these defines in our API header file.

/* Reason for releasing call */
#define UNASSIGNED_NUMBER      0x01  /* Number unassigned / unallocated */
#define NORMAL_CLEARING        0x10  /* Call dropped under normal conditions*/
#define CHANNEL_UNACCEPTABLE   0x06
#define USER_BUSY              0x11  /* End user is busy */
.
.
.

However, I want to pass one to a function but I am not sure of the type. I could pass as just an integer value? The release_call function takes one of these as its parameter. However, I am not sure as the defines are defined as hex notation.

drop_and_release_call(23, 6); /* Dropping call for CHANNEL_UNACCEPTABLE */


uint32_t drop_and_release_call(uint32_t port_num, uint32_t reason)
{
    release_call(port_num, reason);
}

Many thanks for any suggestions,

like image 343
ant2009 Avatar asked Dec 02 '22 06:12

ant2009


2 Answers

0x06 and 6 (and CHANNEL_UNACCEPTABLE) are equivalent. So is 0x11 and 17 (and USER_BUSY). There is no distinction of hexadecimal or decimal to the computer.

(You should write drop_and_release_call(23, CHANNEL_UNACCEPTABLE) for clarity.)

like image 78
kennytm Avatar answered Dec 04 '22 21:12

kennytm


Yes, it's just an integer.

The hexadecimal aspect of it is only important when it's displayed for us to read.

like image 32
pavium Avatar answered Dec 04 '22 20:12

pavium