User forums > Embedded development

Taking into account C99 standard

<< < (3/7) > >>

Pavel_47:
Hello Mgimenez

Here is my source code:

--- 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();
}

--- End code ---

Here is compiler log:

--- Code: ---||=== 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)) ===|

--- End code ---

Here is Compiler settings -> Other options (please see the snapshot).

Best Regards

Pavel

P.S. I also tried with -std=c99 ... the same result

Jenna:
This is not the content of the "Build log"-tab, but from "Build messages".


--- Quote from: Pavel_47 on November 17, 2014, 01:44:04 pm ---
--- Code: ---..\..\Makefile.include|234|recipe for target 'test_cpp_v1.co' failed|

--- End code ---

--- End quote ---
Is it a custom makefile project ?
If yes, the settings you make in compiler tab are ignored, because you do not use C::B's own build-system.
You have to make the needed changes inside the makefile or in the make-comamandline in the "Project -> Build options... -> Make options" (if your makefile supports this).

Pavel_47:
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:

--- Code: ---#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
--- End code ---

Result: nothing changed - the build log is the same:

--- Code: ---||=== 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)) ===|

--- End code ---

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



oBFusCATed:
Sorry but you are changing settings randomly and you're expecting it to magically work.
I have to disappoint you - it won't sooner or later you'll hit the road block.
So if you want to have any success in what you're doing - start reading on Makefiles, compilers, linkers and so on.

stahta01:

--- Quote from: oBFusCATed on November 17, 2014, 08:21:54 pm ---...
So if you want to have any success in what you're doing - start reading on Makefiles, compilers, linkers and so on.

--- End quote ---

I agree with the above; I also suggest you STOP asking about how to fix the Contiki Makefile on this site!

I suggest a site that supports questions on how to write or modify makefiles or a site supporting compiling Contiki.

Edit2: You might try the C Board site http://cboard.cprogramming.com/forum.php

Tim S.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version