Note that there are some explanatory texts on larger screens.

plurals
  1. PONew to C... getting "UArray2.h:19: error: expected ‘)’ before ‘*’ token" on an unfinished function declaration
    primarykey
    data
    text
    <p>I'm working on a CS project for school, but I seem to be getting this odd error which is pretty unhelpful. My partner and I can't seem to figure it out.</p> <p>It says "UArray2.h:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘<strong>attribute</strong>’ before ‘*’ token" on the first function declaration my .h file (UArray2_new).</p> <p>It's followed by repeated "error: expected ‘)’ before ‘*’ token" on every line with a function declaration. Any ideas? I included a blank main in mine, so you could see that it couldn't have been a compile issue. I used "gcc -Wall -Wextra -Werror UArray2.c" for compiling.</p> <pre><code>//UArray2.h #include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; #ifndef UARRAY2_INCLUDED #define UARRAY2_INCLUDED struct UArray2_T{ int width, height; }; extern UArray2_T * UArray2_new(int height, int width, int size); extern void UArray2_free(UArray2_T * uarray2); extern void * UArray2_at(UArray2_T * uarray2, int column, int row); extern int UArray2_size(UArray2_T * uarray2); extern int UArray2_columns(UArray2_T * uarray2); extern int UArray2_rows(UArray2_T * uarray2); static int UArray2_index(UArray2_T * uarray2, int col, int row); #endif </code></pre> <p>And here is the .c file</p> <pre><code>//UArray.c #include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; #include "UArray2.h" int main() { return 0; } UArray2_T * UArray2_new(int height, int width, int size) { T newArray=malloc(sizeof(UArray2_T)); newArray-&gt;height=height; newArray-&gt;width=width; (void) size; return newArray; } void UArray2_free(UArray2_T * uarray2) { (void) uarray2; //need to write } void * UArray2_at(UArray2_T * uarray2, int column, int row) { (void) uarray2; int index=UArray2_index(uarray2, column, row); (void) index; //if(index&gt;0 &amp;&amp; index&lt;=column*row) //return UArray_at(uarray2-&gt;UArray, index); //else //throw an error char * k="hi"; //dummy variables return k; } int UArray2_size(UArray2_T * uarray2) { //UArray_size(uarray2-&gt;UArray); return 0; } int UArray2_columns(UArray2_T * uarray2){ return uarray2-&gt;width; } </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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