Hello Mgimenez
Here is my source code:
#include "contiki.h"
#include <stdio.h> /* For printf() */
void ssi0_isr()
{
}
/*---------------------------------------------------------------------------*/
PROCESS(hello_world_process, "Hello world process");
AUTOSTART_PROCESSES(&hello_world_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(hello_world_process, ev, data)
{
PROCESS_BEGIN();
for(int i=0; i < 10; i++)
{
printf("Hello, world\n");
}
PROCESS_END();
}
Here is compiler log:
||=== Build: Debug in link_v1 (compiler: GNU GCC Compiler for ARM) ===|
test_cpp_v1.c||In function 'process_thread_hello_world_process':|
test_cpp_v1.c|16|error: 'for' loop initial declarations are only allowed in C99 mode|
test_cpp_v1.c|16|note: use option -std=c99 or -std=gnu99 to compile your code|
..\..\Makefile.include|234|recipe for target 'test_cpp_v1.co' failed|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
Here is Compiler settings -> Other options (please see the snapshot).
Best Regards
Pavel
P.S. I also tried with -std=c99 ... the same result
Hello Jens
Thank you for suggestions.
I've tried both (at least as I understood them)
1. Changing custom makefile ... I included "-std=c99" on the top of makefile:
#DEFINES+=PROJECT_CONF_H=\"project-conf.h\"
-std=c99
all: test_cpp_v1
APPS=servreg-hack
CONTIKI=../..
UIP_CONF_IPV6=1
#SERVER_REPLY=1
CFLAGS+= -DUIP_CONF_IPV6_RPL
ifdef WITH_COMPOWER
APPS+=powertrace
CFLAGS+= -DCONTIKIMAC_CONF_COMPOWER=1 -DWITH_COMPOWER=1 -DQUEUEBUF_CONF_NUM=4
endif
ifdef SERVER_REPLY
CFLAGS+=-DSERVER_REPLY=$(SERVER_REPLY)
endif
ifdef PERIOD
CFLAGS+=-DPERIOD=$(PERIOD)
endif
include $(CONTIKI)/Makefile.include
Result: nothing changed - the build log is the same:
||=== Build: Debug in link_v1 (compiler: GNU GCC Compiler for ARM) ===|
test_cpp_v1.c||In function 'process_thread_hello_world_process':|
test_cpp_v1.c|16|error: 'for' loop initial declarations are only allowed in C99 mode|
test_cpp_v1.c|16|note: use option -std=c99 or -std=gnu99 to compile your code|
..\..\Makefile.include|234|recipe for target 'test_cpp_v1.co' failed|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
2. Changing make-commandlinein the "Project -> Build options... -> Make options" ... instead of "$make -f $makefile" I've put "$make -std c99 -f $makefile".
After having run "Build" the "Build messages" window are rapidly filled with endless messages ... I was need to abort.
Regards
Pavel
h files are not passed to the compiler over parameter. You have to set the path to your include files over Project->Build Options-> Search directories->Compiler. Don forget to select on the left site the right target (or the project name if you want apply this setting project wide)
Thank you BlueHazzard
It's more clear now. I followed your suggestions and now compilation seems to proceed in right way.
Nevertheless errors occurs ... this time caused by code. I've already posted them on gcc forum, but also repeat it here hoping that someone already faced such cases (please, see the Build log on the image below).
From the core of error message it follows that processor selection is wrong, but I didn't specify any processor in compiler settings.
I founded the code that caused the problem. It's located inside of startup-gcc.c file (the last name in compiler command). Here is this code (extract):
/* Zero-fill the bss segment. */
__asm(" ldr r0, =_bss\n"
" ldr r1, =_ebss\n"
" mov r2, #0\n"
" .thumb_func\n"
"zero_loop:\n"
" cmp r0, r1\n"
" it lt\n"
" strlt r2, [r0], #4\n" " blt zero_loop");
/* call the application's entry point. */
Besides the compiler problem I've another question (I didn't find answer in Code::Block manual) - is there a possibility to "integrate" in some way the code from Makefile.include file, that configure all necessary option for compiler depending on TARGET. The reference on this file is included in all custom contiki project. Such thing would grately simplify project making with Code::Blocks (you can see this file in attachement).
Thanks in advance
Have you read my post?
As conclusion: I recommend you to use the build system contiki provides you. With this you will be on a fast track of success. If you know more details about the build process you can start to port this to c::b. Anyway this could be great fun, but also great work...
1. Sure, I've red your post with attention.
2. ... use the build system contiki provides you ... there were exactly the fashion I proceed unless I've tried to make my code more compact ... matches c99 standard, use containers like <vector>, dictionary, etc...
Implementation of these features caused compilation errors. So I addressed to this forum for help.
During followed discussions some experts suggested me to resign custom makefiles if I hope to have assistance on this forum.
That's what I did afterwards ... and faced difficulties.
So here I reform my original question: is it possible to use custom makefile and add some compiler options via Code::Block interface ?
After all some options in Code::Block UI remains active even if I specify custom makefile. Isn't it ?
Othewise how compilation is made if compiler executables aren't specified in the custom makefile ?
To be more close to problem, the compilation of the following code causes error:
for(int i=0; i < 10; i++)
{
printf("Hello, world\n");
}
Here is built output:
hello-world.c: In function 'process_thread_hello_world_process':
hello-world.c:53:5: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
for(int i=0; i < 10; i++)
^
hello-world.c:53:5: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
make: *** [hello-world.co] Error 1
../../Makefile.include:234: recipe for target 'hello-world.co' failed
rm obj_cc2538dk/startup-gcc.o
Process terminated with status 2 (0 minute(s), 2 second(s))
2 error(s), 0 warning(s) (0 minute(s), 2 second(s))
Then I've tried to add the suggested option in the following location Compiler settings->Other options (following to some suggestion)
-std=gnu99
Without any effect ...
Thanks in advance