Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As others have pointed out, the problem is that you're passing the wrong type of argument to <code>userComFunction</code>. But the real problem is that your compiler isn't telling you that.</p> <p>As of C90 (that's two standards ago), calling a function with no visible declaration was legal, and the compiler would make assumptions (often incorrect) about what the function actually looks like. When the compiler sees the call to <code>userComFunction</code>, it hasn't seen a declaration or definition for <code>userComFunction</code>, so it can't diagnose your error.</p> <p>As of C99, calling a function with no visible declaration is a <em>constraint violation</em>, meaning that a compiler must at least warn you about it. C99 also dropped the "implicit <code>int</code>" rule, so you can no longer omit the return type in a function declaration; <code>main</code> should be declared with an <code>int</code> return type (<em>not</em> <code>void</code>!), and <code>userComFunction</code>, since it doesn't return anything, should be <code>void</code>.</p> <p>You can either move the full definition of <code>userComFunction</code> above the definition of <code>main</code>, or you can leave the definition where it is and add a "forward" declaration:</p> <pre><code>void userComFunction(struct userCom *return_type); int main(void) { /* ... */ } void userComFunction(struct userCom *return_type) { /* ... */ } </code></pre> <p>When you do that, the compiler should let you know that your call:</p> <pre><code>userComFunction(com); </code></pre> <p>is incorrect. (The fix is to change <code>com</code> to <code>&amp;com</code>.)</p> <p>You should also use gcc's command-line options to enable more warnings. For example:</p> <pre><code>gcc -std=c99 -pedantic -Wall -Wextra </code></pre> <p><code>-std=c99</code> says to enforce ISO C99 rules. <code>-pedantic</code> says to <em>really</em> enforce those rules. <code>-Wall</code> and <code>-Wextra</code> enable additional warnings.</p>
    singulars
    1. This table or related slice is empty.
    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. 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.
    3. VO
      singulars
      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