Page 1 of 1

"Parse error" causing "conflicting types" with "previous declaration" back to line of parse error

Posted: Tue Sep 19, 2017 10:05 am
by aclassifier
I have made a local copy of app_tiwisl_simple_webserver called _app_tiwisl_simple_webserver.

The system has compiled fine and works as expected I guess. I have discussed it in http://www.teigfam.net/oyvind/home/tech ... otes-wifi/

module_wifi_tiwisl has been modified, I have added wifi_led_server.h and wifi_led_server.xc (incomplete). I use git repositories.

xmake complains about .build/src/xhttpd.xc.pca.xml.decouple which I can't find (I see "invisible" files). It may not have been stored to disk.

Speculative: I don't know if this started when I originally had created wifi_led_server.h and wifi_led_server.xc in the build project _app_tiwisl_simple_webserver and then later on dragged and dropped them down to module_wifi_tiwisl, which is the right place I guess. Then delete them in _app_tiwisl_simple_webserver. However, when I now tried to delete them in module_wifi_tiwisl and create them anew (with contents copied from copies) it didn't help.

I saw an include of wifi_tiwisl_server.h in wifi_tiwisl_spi.h that I removed, no help.

Is there some kind of relationship here that I don't see? The built and the used modules? Hmm..

Both 14.3.0 and 14.2.4 give the same error.

I'd certainly like a hint to learn how to get around this.

==== BUILD LOG (also attached) ====

Code: Select all

20:34:56 **** Build of configuration Default for project _app_tiwisl_simple_webserver ****
xmake all 
Checking build modules
Using build modules: module_spi_master module_wifi_tiwisl
Analyzing httpd.c
Analyzing hci_helper.c
Analyzing hci_pkg.c
Analyzing tiwisl_event_handler.c
Analyzing main.xc
Analyzing xhttpd.xc
In file included from ../src/xhttpd.xc:1:
../src/xhttpd.h:11:56: error: parse error before "i_wifi_led_server"
void xhttpd (chanend c_wifi, client wifi_led_server_if i_wifi_led_server);
                                                       ^
../src/xhttpd.xc:56:6: error: conflicting types for 'xhttpd'
void xhttpd (chanend c_wifi, client wifi_led_server_if i_wifi_led_server)
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/xhttpd.h:11:1: note: previous declaration of 'xhttpd' was here
void xhttpd (chanend c_wifi, client wifi_led_server_if i_wifi_led_server);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xmake[1]: *** [.build/src/xhttpd.xc.pca.xml.decouple] Error 1
xmake: *** [analyze] Error 2
 
20:34:57 Build Finished (took 899ms)

Re: "Parse error" causing "conflicting types" with "previous declaration" back to line of parse error

Posted: Tue Sep 19, 2017 12:40 pm
by mon2
Hi. Both declarations appear to be the same. Please comment out one of the declarations, save and recompile to test again. Guessing the issue is the double declarations.

Re: "Parse error" causing "conflicting types" with "previous declaration" back to line of parse error

Posted: Tue Sep 19, 2017 2:37 pm
by aclassifier
Thanks. But there is only one declaration, in the header file xhttpd.h. It seems like the compiler sees it two times in different contexts, since it starts with

Code: Select all

../src/xhttpd.h:11:56: error: parse error before "i_wifi_led_server"
void xhttpd (chanend c_wifi, client wifi_led_server_if i_wifi_led_server);
                                                       ^
Then it tells that it has seen it before, and at that very line.

If I comment away the only declaration there is, in xhttpd.h I get this expected result:

Code: Select all

Compiling main.xc
../src/main.xc:41:19: error: unknown function identifier `xhttpd' (possibly missing prototype?)
      on tile[0]: xhttpd(c_wifi, i_wifi_led_server[1]); // The main webserver thread is here
                  ^
xmake[1]: *** [.build/src/main.xc.o] Error 1
xmake: *** [bin//_app_tiwisl_simple_webserver.xe] Error 2
But I'd certainly like any thread here!

Re: "Parse error" causing "conflicting types" with "previous declaration" back to line of parse error

Posted: Tue Sep 19, 2017 3:16 pm
by aclassifier
I have a fix. I moved #include "xhttpd.h" between wifi_led_server.h and wifi_tiwisl_server.h

in main.xc

Code: Select all

#include "wifi_led_server.h" // Added by Teig
#include "xhttpd.h"
#include "wifi_tiwisl_server.h"
and in xhttpd.xc:

Code: Select all

#include "httpd.h"
#include "wifi_led_server.h" // Added by Teig
#include "xhttpd.h"
#include "wifi_tiwisl_server.h"
I was so confused by the rather strange accusation by the compiler that it had seen something defined before at the exact place where I knew it had seen something, that I thought it a compiler error.

I guess this isn't called compiler error in C/XC, since it certainly stops me. Great.

But I still think a less confusing error message could have been given, or isn't that possible or even wanted?