Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>void change_AArray() { *AArray[0] = *((TYPEA*) &amp;gb); //#1 /* error: *(AArray[0]) = (TYPEA) gb; //#2 */ } </code></pre> <p>You can use #1 for your purpose.</p> <p>If use #2, gcc reports an error:<br> error: conversion to non-scalar type requested</p> <p>Questions are:<br> - What's scalar/non-scalar type?<br> - What does this error message mean?<br> - Why #2 fails? </p> <p>What's scalar/non-scalar type?<br> int, char, pointers are scalar type, and a structure is not.<br> See details here,<a href="http://herbert.the-little-red-haired-girl.org/en/prgmsc1/docs/part2a.pdf" rel="nofollow noreferrer">http://herbert.the-little-red-haired-girl.org/en/prgmsc1/docs/part2a.pdf</a></p> <p>What does this error message mean?<br> If you do assignment between scalar and non-scalar type, you'll get this error.</p> <p>Why #2 fails?<br> For <code>*(AArray[0]) = (TYPEA) gb;</code>, both sides are non-scalar types. So, it looks like it shouldn't get the above error.<br> However, C doesn't allow cast between structures. See <a href="http://msdn.microsoft.com/en-us/library/d9f2bsy2.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/d9f2bsy2.aspx</a>.</p> <p>A test program,</p> <pre><code>struct a{ int i;}; struct b{ int i; }; int main (int argc, char *argv[]) { struct a aaa; struct b bbb; bbb = (struct b)aaa; return 0; } </code></pre> <p>gcc reports an error: <code>error: conversion to non-scalar type requested</code></p> <p>So to conclude, the reason for failure of #2 is that C language doesn't allow cast between structures.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload