1. c type short int to euphoria int conversion

I'm calling a c api that returns a boolean value (defined as a unsigned short int in the c header file) and I assign this to a euphoria integer. Since the boolean value is an error code either a 1 or 0. When I test the Euphoria integer I don't get a 1 but some other value. Is it safe for me to assume that anything other than a 0 is the same as a 1 in the short int I retrieve and that if the short int is a zero it will still be a zero when assigned to eu integer. Or am I way off and there is a better way. Thanks

new topic     » topic index » view message » categorize

2. Re: c type short int to euphoria int conversion

cp said...

I'm calling a c api that returns a boolean value (defined as a unsigned short int in the c header file) and I assign this to a euphoria integer. Since the boolean value is an error code either a 1 or 0. When I test the Euphoria integer I don't get a 1 but some other value. Is it safe for me to assume that anything other than a 0 is the same as a 1 in the short int I retrieve and that if the short int is a zero it will still be a zero when assigned to eu integer. Or am I way off and there is a better way. Thanks

C is similar to euphoria in that 0 is considered false, and any other value is true. A short int is a 16 bit value, which is smaller than a euphoria integer, so you're not losing any information.

What value do you get in the return? Is it always the same? Do you have access to the source code for whatever library you're calling?

Matt

new topic     » goto parent     » topic index » view message » categorize

3. Re: c type short int to euphoria int conversion

The eu integer value is 91 and I get the same value every time. I don't have access to the source code, but I do have access to the c header file for the library.

new topic     » goto parent     » topic index » view message » categorize

4. Re: c type short int to euphoria int conversion

cp said...

The eu integer value is 91 and I get the same value every time. I don't have access to the source code, but I do have access to the c header file for the library.

I'm calling a c api that returns a boolean value (defined as a unsigned short int in the c header file)

BOOLEAN is a SIGNED value not an UNSIGNED value.

new topic     » goto parent     » topic index » view message » categorize

5. Re: c type short int to euphoria int conversion

here is the definition in the api header:

typedef unsigned short TM1_BOOL; boolean flag

new topic     » goto parent     » topic index » view message » categorize

6. Re: c type short int to euphoria int conversion

cp said...

here is the definition in the api header:

typedef unsigned short TM1_BOOL; boolean flag

Yup, that's a 16-bit value. I'd assume that any zero value is false, and any non-zero value is true.

Matt

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu