User forums > Embedded development

Taking into account C99 standard

<< < (6/7) > >>

BlueHazzard:
I think you have to understand what c::b (code::blocks) and make is. You are confusing thing up like hell...
So i will try to explain a bit:
Code blocks is a IDE. Basically a editor which helps you compile c and c++ programs, but it is not a compiler.
Make files are the "old", but probably most used way to manage the build process.

If you are using custom make files in c::b you use c::b as pure editor. The whole compiler options tabs and so on are not forwarded to make. Only the make file, and the target name.

If you are using c::b as build manager you can use targets and the compiler options tabs...

i hope this makes things more clear. I would suggest you to read a bit about compiler and make or c::b, because at a certain point you will need to know what you are doing, and right now i think you have no plan about the whole build process...

greetins

Pavel_47:

--- Quote from: BlueHazzard on January 22, 2015, 10:07:26 pm ---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)

--- End quote ---

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

--- Code: ---  /* 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. */

--- End code ---

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

BlueHazzard:
Have you read my post?
If you are using a custom make file, you use c::b only as ide, without the whole build management system...


--- Quote from: Pavel_47 on January 23, 2015, 12:13:56 pm ---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):

--- End quote ---

They will have fun on the gcc forum, when you come with this questions. I think your project is clearly miss configured to build smooth, so this is no code error but your configuration error. It seems that contiki is a large project, and that they are using makefiles to build theirs code. So i recommend you (unless you are really willing to go deep in their build system and port it to the c::b build system) to use their build system...

You are in better hands if you go to the contiki forum/mailing list/ chat, and ask how their build system work, and what minimal files you need to use it, and then you can come back and ask us, how you apply this settings in a c::b project...


--- Quote from: Pavel_47 on January 23, 2015, 12:13:56 pm ---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).

--- End quote ---
I don't think that it is possible to use a make configuration file in the build system of c::b unless you use only make (and so you use c::b ONLY as editor). This two systems are completely different... (maybe you can miss use the pre and post build steps, to set the correct global variables that gcc uses, but i think this is complex, and you really need a deep understanding of the build process, and the code structure of contiki)


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...

greetings

Pavel_47:

--- Quote from: BlueHazzard on January 23, 2015, 12:42:11 pm ---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...

--- End quote ---

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:

--- Code: ---    for(int i=0; i < 10; i++)
    {
        printf("Hello, world\n");
    }
--- End code ---

Here is built output:

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

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

BlueHazzard:
can you post your current project file?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version