Author Topic: Taking into account C99 standard  (Read 26285 times)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7056
    • My Best Post
Re: Taking into account C99 standard
« Reply #15 on: November 17, 2014, 08:54:48 pm »
The places in CB that I believe matter to custom makefile projects.
Not sure if Execution Directory matter or not.

Project -> Properties
Tab: Project Settings
Checkbox: "This is a custom makefile"
Textbox: "Makefile:"
? Execution Directory

Project -> Properties
Tab: Build Targets

Project -> "Build Options"
Tab: "Make" commands

Settings -> Compiler
Tab: Toolchain Excutables
Textbox: "Make Program:"

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7056
    • My Best Post
Re: Taking into account C99 standard
« Reply #16 on: November 19, 2014, 06:06:34 pm »
The places in CB that I believe matter to custom makefile projects.
Not sure if Execution Directory matter or not.

Project -> Properties
Tab: Project Settings
Checkbox: "This is a custom makefile"
Textbox: "Makefile:"
? Execution Directory

Project -> Properties
Tab: Build Targets

Project -> "Build Options"
Tab: "Make" commands

Settings -> Compiler
Tab: Toolchain Excutables
Textbox: "Make Program:"

Tim S.


FYI: I just tried using Code::Blocks and Cygwin to build Contiki Hello world it built OK

Link to my Project is here https://github.com/stahta01/contiki/blob/master/examples/hello-world/hello_world-cygwin.cbp

Edit: Links to second project and readme for CB file:
https://github.com/stahta01/contiki/blob/master/platform/win32/platform_win32-cygwin.cbp
https://github.com/stahta01/contiki/blob/master/README-CodeBlocks.txt


Tim S.
« Last Edit: November 20, 2014, 04:07:12 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: Taking into account C99 standard
« Reply #17 on: January 22, 2015, 04:39:55 pm »
Hello Tim,

I've tried without custom make.
Here is buil log of hello_world:
"hello_world MinGW - Makefile": The compiler's setup is invalid, so Code::Blocks cannot find/run the compiler.
Probably the toolchain path within the compiler options is not setup correctly?! (Do you have a compiler installed?)
Goto "Settings->Compiler...->Global compiler settings->unknown->Toolchain executables" and fix the compiler's setup.
Skipping...
Nothing to be done (all items are up-to-date).


Here is my compiler settings. All executables does exist in specified location.


[attachment deleted by admin]

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: Taking into account C99 standard
« Reply #18 on: January 22, 2015, 06:23:51 pm »
In the "make commands" tab there is target that I want to modify
But edit fields aren't editable.
How to change target ?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7056
    • My Best Post
Re: Taking into account C99 standard
« Reply #19 on: January 22, 2015, 06:44:24 pm »
Do you have the make.exe in the bin folder for your compiler?
Does the C compiler exe exist in the bin folder for your compiler?

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7056
    • My Best Post
Re: Taking into account C99 standard
« Reply #20 on: January 22, 2015, 06:46:19 pm »
Attach the zipped CB project or at least post the full build log.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7056
    • My Best Post
Re: Taking into account C99 standard
« Reply #21 on: January 22, 2015, 06:49:30 pm »
In the "make commands" tab there is target that I want to modify
But edit fields aren't editable.
How to change target ?

IS IT A CUSTOM MAKE CB PROJECT OR IS IT NOT!!!!

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: Taking into account C99 standard
« Reply #22 on: January 22, 2015, 07:36:34 pm »
Not !
The "this is  the custom Makefile" is unchecked.
Doing some manipulations with project (removing your platform and adding cc2538dk) I've discovered in some moment that make commands became "editable",
so I changed the TARGET value for CC2538dk.
Then I've tried to compile ... compilation failed (for some other reasons).
But then, when I came back to make commands tab, it became "passive" once more.

Mystery ...

Answering to your previous question concerning make.exe, it isn't inside compiler directory, but in another place, for which I've specified the path (please, see the image below)




Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: Taking into account C99 standard
« Reply #23 on: January 22, 2015, 09:11:08 pm »
Well, working with Code::Blocks requires a lot of attention and also ... habit.
Indeed, modifying of TARGET is possible only if option "this is the custom Makefile" is desactivated.
But after modifying of any option one must confirm by Ok in the the "Project/Target" window, and it seems also save the project, otherwise it's total confusion.

So in abscence of custom makefile, the TARGET is defined only by platform directories, attached to project - i.e. there is no any option in the project settings, allowing to define TARGET, isn't it ?

If this is a case, there are still problems: the compiler "doesn't see" a .h file, that is attached to project (please see the picture).

Where is a problem ?

Thanks in advance.

Sincerely ...


[attachment deleted by admin]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2862
Re: Taking into account C99 standard
« Reply #24 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)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2862
Re: Taking into account C99 standard
« Reply #25 on: January 22, 2015, 10:18:23 pm »
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

Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: Taking into account C99 standard
« Reply #26 on: January 23, 2015, 12:13:56 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)

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: [Select]
  /* 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

« Last Edit: January 23, 2015, 12:16:24 pm by Pavel_47 »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2862
Re: Taking into account C99 standard
« Reply #27 on: January 23, 2015, 12:42:11 pm »
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...

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

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

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


Offline Pavel_47

  • Multiple posting newcomer
  • *
  • Posts: 66
Re: Taking into account C99 standard
« Reply #28 on: January 23, 2015, 01:39:10 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...

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: [Select]
    for(int i=0; i < 10; i++)
    {
        printf("Hello, world\n");
    }

Here is built output:
Code: [Select]
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

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2862
Re: Taking into account C99 standard
« Reply #29 on: January 23, 2015, 01:45:45 pm »
can you post your current project file?