Recent Posts

Pages: 1 2 3 [4] 5 6 7 8 9 10
Plugins development / New plugin: Premake5 exporter (premake5cb)
« Last post by cacb on July 20, 2021, 12:08:30 pm »
Hi all,

I have many Code::Blocks workspaces and enjoy the IDE, thanks for the great work done by the C::B developers!  Sometimes, however, I need to share my work with others who do not use Code::Blocks. Some people expect Visual Studio solutions for example, so I was considering how to do it.

It was suggested to me to maintain a separate CMake script along the C::B workspace/projects, but that idea did not appeal to me. I do want the convenience of Code::Blocks, I don't want to maintain a parallel build system and finally I think the CMake syntax is awful and difficult.  Therefore, a different idea was instead to create a Code::Blocks plugin to automatically generate a  Premake5 script, because Premake5 seems well structured and well documented. It can generate GNU makefiles as well as Visual Studio solutions. Thus, the idea of Premake5 exporter plugin for Code::Blocks was born.

Of course, some will say this can never work and it is a bad idea. In a way it is true, because there will always be examples that don't work properly. Still, if I can apply some assumptions and make it work for my Code::Blocks workspaces, it is still useful to me, and quite possibly to others as well.

You can find the plugin at , please see the README documentation with screenshots there.

An example Code::Blocks workspace at .

The plugin currently builds on Linux only, it is possible that the project file does not correspond 100% to other plugins, I had to tweak it to make it work, but it does work fine here, and it is even possible to generate the required Visual Studio solution with premake5 under Linux.

If you have constructive suggestions, please share. This is somewhat experimental at this stage!
Help / Re: Wizard script and variables expansion
« Last post by ValeV on July 20, 2021, 07:40:24 am »
Where does it crash (backtrace/callstack)?

When I try to create new header file with this custom script at the last step, when I click "Finish" in the wizard.

What version are you using?

Latest, CodeBlocks 20.03.

What is the exact wizard script and steps to reproduce?

I copy pasted the exact wizard script to the first message. Steps to reproduce is 1. create new custom script, 2. add it to global registration script, 3. create new header file with this custom script.

If I remove
text.Replace(_T("[DATE]"), "$(TODAY)");
from my script it works fine, so it looks clear where the problem is. So my question is how to insert current date to wizard script.
Works fine and it leads to "TDM-Gcc is discontinued" where TDM failures are discussed. I've not linked a particular post.
Try the link as it does not work for me.
Help / Re: Wizard script and variables expansion
« Last post by oBFusCATed on July 19, 2021, 09:17:01 pm »
Where does it crash (backtrace/callstack)?
What version are you using?
What is the exact wizard script and steps to reproduce?
@oBFusCATed There are 6 forum posts after 2010 that reference TDM I have listed below. I also looked at the tickets and there is noting about TDM  "it is broken and produces failing code" that I could find.,23642.0.html

Using Code::Blocks / Re: Mixing C and C++ code linker option
« Last post by stefanofranzoni on July 19, 2021, 04:09:56 pm »
Tim, thanks for your reply.

My version of Codeblocks is 20.03.

Your suggestion solves my problem.

I noticed however that it is not necessary to add "Use C ++ compiler" in the linker options when using Codeblocks as administrator ie running "sudo Codeblocks".

The problem is reproducible with two simple files, one in C and the other in C ++.

Help / Wizard script and variables expansion
« Last post by ValeV on July 19, 2021, 03:31:33 pm »

I am creating new wizard script for generating C header files. I want to add date to the top of the file (where [DATE] is in the code below). I tried to use variable expansion $(TODAY), but CodeBlocks crashes on creating new such header file.

// Code::Blocks new file wizard script
// Project: C/C++ header file

header_contents <- @"/**************************************************************************//**
 * \file
 * \brief
 * \author
 * \version
 * \date [DATE]

#ifndef IG_[GUARD]
#define IG_[GUARD]

/*========================== function prototypes =================================*/

#endif // IG_[GUARD]

function BeginWizard()
    // this is the text that will appear in the start (intro) page
    local intro_msg = _T("Welcome to the new C/C++ header file wizard!\n" +
                         "This wizard will guide you to create a new C/C++ header file.\n\n" +
                         "When you 're ready to proceed, please click \"Next\"...");

    // add builtin pages
    //Wizard.AddInfoPage(_T("HFileIntro"), intro_msg); // intro
    Wizard.AddFilePathPage(true); // select filename (header guard required for header files)

    Wizard.SetFilePathSelectionFilter(_T("C/C++ header files (*.h;*.hpp;*.hxx;*.hh)|*.h;*.hpp;*.hxx;*.hh"));

function CreateFiles()
    local fname = Wizard.GetFileName();
    local ed    = GetEditorManager();
    if (IsNull(ed))
        ShowError(_T("The wizard could not locate the editor manager."));

    local ed_new = ed.New(fname);
    if (IsNull(ed_new))
        ShowError(_T("The wizard could not create a new file.\n" +
                     "Maybe the target folder is write-protected?"));
        // succeeded -> add header guard
        local guard = Wizard.GetFileHeaderGuard();
        local text = _T(header_contents);
        local auto_text = ed_new.GetText();

        text.Replace(_T("[DATE]"), "$(TODAY)");

        text.Replace(_T("[GUARD]"), guard);
        //text.Replace(_T("AUTO_GENERATED_CONTENTS"), auto_text);

        // succeeded -> add file to project if needed
        if (Wizard.GetFileAddToProject())
            AddFileToTargets(Wizard, fname);
    return fname;

Is there a different way for inserting current date?

Using Code::Blocks / Re: Mixing C and C++ code linker option
« Last post by stahta01 on July 19, 2021, 03:25:02 pm »
CB Version info is needed; the option below is less than 3 years old IIRC.

CB Version SVN 12452

Project -> Build Options
Tab: Linker Settings
Linker Executable: "Auto Detect" likely needs changed to "Use C++ Compiler"

Tim S.

Using Code::Blocks / Mixing C and C++ code linker option
« Last post by stefanofranzoni on July 19, 2021, 03:17:10 pm »
My project contains C code and uses an external library written in C++.
The linker is normally g++ but on an Ubuntu 20.04 installation he automatic linker choice is gcc and it generates many errors.
I don't find an option to force the linker to g++ while keeping the compiler to gcc.

Thanks in advance
Stefano Franzoni
Pages: 1 2 3 [4] 5 6 7 8 9 10