Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion A couple of enum and type questions
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sarvi Shanmugham  
View profile  
 More options Sep 28 2012, 12:07 pm
From: Sarvi Shanmugham <sarvil...@gmail.com>
Date: Fri, 28 Sep 2012 09:07:24 -0700 (PDT)
Local: Fri, Sep 28 2012 12:07 pm
Subject: A couple of enum and type questions

1. I have an enum as follows
typedef enum my_thread_sched_mode_ {
    MY_THREAD_MODE_NORMAL = 0,
    MY_THREAD_MODE_NON_PREEMPTIVE = 0xffffffff,

} my_thread_sched_mode;

This generates code as
int _cffi_e_enum_my_thread_sched_mode_(char *out_error)
{
  if (MY_THREAD_MODE_NORMAL != 0) {
    snprintf(out_error, 255, "in enum %s: %s has the real value %d, not %d",
            "my_thread_sched_mode_", "MY_THREAD_MODE_NORMAL",
(int)MY_THREAD_MODE_NORMAL, 0);
    return -1;
  }
  if (MY_THREAD_MODE_NON_PREEMPTIVE != 4294967295) {
    snprintf(out_error, 255, "in enum %s: %s has the real value %d, not %d",
            "my_thread_sched_mode_", "MY_THREAD_MODE_NON_PREEMPTIVE",
(int)MY_THREAD_MODE_NON_PREEMPTIVE, 4294967295);
    return -1;
  }
  return 0;
}

The second snprintf causes a warning
__pycache__/_cffi__g644663dbx82c763c2.c:910: warning: this decimal constant
is unsigned only in ISO C90
__pycache__/_cffi__g644663dbx82c763c2.c:912: warning: this decimal constant
is unsigned only in ISO C90
__pycache__/_cffi__g644663dbx82c763c2.c:912: warning: format '%d' expects
type 'int', but argument 7 has type 'long unsigned int'
__pycache__/_cffi__g644663dbx82c763c2.c:912: warning: format '%d' expects
type 'int', but argument 7 has type 'long unsigned int'

I am guessing this is caused by the 0xffffffff
Is this a limitation of some sort, can it be eliminated.

2. There is warnings such as
__pycache__/_cffi__g644663dbx82c763c2.c: In function
'_cffi_f_my_dm_execute':
__pycache__/_cffi__g644663dbx82c763c2.c:619: warning: passing argument 2 of
'my_dm_execute' from incompatible pointer type

for code generated as follows
int _cffi_f_my_dm_execute(struct my_dm_handle_*  x0, void(* x1)(struct
my_dm_handle_* , long, uint64), long x2, uint64 *x3)
{
  return my_dm_execute(x0, x1, x2, *x3);

}

From cdef as follows
typedef void (*my_dm_exec_handler)(my_dm_handle xdm, intptr_t data,
                                    uint64 modifier);
int my_dm_execute(my_dm_handle xdm, my_dm_exec_handler h, intptr_t data,
           uint64 modifier);

I can see that this has something to do with the way intptr_t and uint64 is
being translated/defined in the generated code
and the way it is defined in the actual function definition in the library.

My question: What is the easy way to figure out what the right type should
be.
I have tried generating the myfile.E files with the macro expansion done,
but doesn't seem to be helping.
Any ideas.
sarvi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.