- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is:
extern cyg_uint8 gr_data_written[]; the same as? extern cyg_uint8 *gr_data_written; retrieving via { unsigned char *dp; dp = gr_data_written; my ecos gcc sets dp as the pointer if gr_data_written is declared the first way and as contents if declared the second way. Should it be the same?Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The question is not clear enough.
You'd better show a simple example.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by david_cai@Oct 24 2006, 07:16 PM the question is not clear enough.
you'd better show a simple example.
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=18886)
--- quote end ---
--- Quote End --- Example: // in declaration file cyg_uint8 gr_data_written[5] = {1,2,3,4,5}; --- // in this other file# ifdef FIRSTWAY extern cyg_uint8 gr_data_written[];# else extern cyg_uint8 *gr_data_written;# endif showme() { printf ("%x", (int) gr_data_written); # ifdef FIRSTWAY output of printf is a ptr "4A178";# else output of printf is the value "1";# endif ----------- I thought it was supposed to be the same either way, but it wasn't.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think it is related to declaring a pointer vs. declaring an array.
Note, the *gr_data_written pointer is not declared anywhere nor initialized. Thus, the result should be undefined. When declaring, pointer and array are different. Garland --- Quote Start --- originally posted by itntest+oct 26 2006, 05:23 pm--><div class='quotetop'>quote (itntest @ oct 26 2006, 05:23 pm)</div>--- quote start ---
<!--quotebegin-david_cai@Oct 24 2006, 07:16 PM the question is not clear enough.
you'd better show a simple example.
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=18886)
--- quote end ---
--- Quote End --- Example: // in declaration file cyg_uint8 gr_data_written[5] = {1,2,3,4,5}; --- // in this other file# ifdef FIRSTWAY extern cyg_uint8 gr_data_written[];# else extern cyg_uint8 *gr_data_written;# endif showme() { printf ("%x", (int) gr_data_written); # ifdef FIRSTWAY output of printf is a ptr "4A178";# else output of printf is the value "1";# endif ----------- I thought it was supposed to be the same either way, but it wasn't. <div align='right'><{post_snapback}> (index.php?act=findpost&pid=18938)</div> [/b] --- Quote End ---
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not convinced yet.
Thoughts from anyone else?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please try the following.
<span style="font-family:Courier">// in declaration file cyg_uint8 gr_data_written[5] = {1,2,3,4,5}; cyg_uint8 *pData = gr_data_written; // initialize the pointer //--- // in this other file extern cyg_uint8 gr_data_written[]; // good extern cyg_uint8 *pData ; // good </span> Good luck! Garland
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page