Studio:Can an array be cast to a pointer?: Difference between revisions

From STRIDE Wiki
Jump to navigation Jump to search
No edit summary
m (Text replace - 'Category:Pointers' to 'Category:Studio:Pointers')
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
No. You cannot cast an array to a pointer type. Because there are subtle differences between them, they are not always interchangeable in SCL like they are in C.
No. You cannot cast an array to a pointer type. Because there are subtle differences between them, they are not always interchangeable in SCL like they are in C.


Instead of using the following:<br>
Instead of using the following:
  <tt>INT vr_get_foo(INT entry, INT index, file_table_t * out_buffer)<br>
<source lang="c">
typedef struct<br>
  INT vr_get_foo(INT entry, INT index, file_table_t * out_buffer)
{<br>
typedef struct
    register ringer_types_t ringer_type;<br>
{
    BYTE alias_filename[(MAX_RINGER_ALIAS_NAME_LEN+1) *2];<br>
    register ringer_types_t ringer_type;
    UINT16 pad;<br>
    BYTE alias_filename[(MAX_RINGER_ALIAS_NAME_LEN+1) *2];
}ringer_file_table_t;<br><br>
    UINT16 pad;
#pragma scl_function(v_get_mmedia_ringer)<br>
}ringer_file_table_t;
#pragma scl_ptr(vr_get_mmedia_ringer, out_buffer, OUT, PRIVATE)<br></tt><br>
#pragma scl_function(v_get_mmedia_ringer)
#pragma scl_ptr(vr_get_mmedia_ringer, out_buffer, "OUT", PRIVATE)
</source>


Use this SCL instead:<br>
Use this SCL instead:
<tt>#pragma scl_function(vr_get_mmedia_ringer)<br>
<source lang="c">
#pragma scl_ptr(vr_get_get_mmedia_ringer, out_buffer, OUT, PRIVATE)<br>
#pragma scl_function(vr_get_mmedia_ringer)
#pragma scl_string(ringer_file_table_t, alias_filename, (MAX_RINGER_ALIAS_NAME_LEN+1) * 2)</tt>
#pragma scl_ptr(vr_get_get_mmedia_ringer, out_buffer, "OUT", PRIVATE)
#pragma scl_string(ringer_file_table_t, alias_filename, (MAX_RINGER_ALIAS_NAME_LEN+1) * 2)
</source>


 
[[Category:Studio:Pointers]]
[[Category:KB]]

Latest revision as of 00:41, 21 August 2009

No. You cannot cast an array to a pointer type. Because there are subtle differences between them, they are not always interchangeable in SCL like they are in C.

Instead of using the following:

 INT vr_get_foo(INT entry, INT index, file_table_t * out_buffer)
typedef struct
{
    register ringer_types_t ringer_type;
    BYTE alias_filename[(MAX_RINGER_ALIAS_NAME_LEN+1) *2];
    UINT16 pad;
}ringer_file_table_t;
#pragma scl_function(v_get_mmedia_ringer)
#pragma scl_ptr(vr_get_mmedia_ringer, out_buffer, "OUT", PRIVATE)

Use this SCL instead:

#pragma scl_function(vr_get_mmedia_ringer)
#pragma scl_ptr(vr_get_get_mmedia_ringer, out_buffer, "OUT", PRIVATE)
#pragma scl_string(ringer_file_table_t, alias_filename, (MAX_RINGER_ALIAS_NAME_LEN+1) * 2)