Recent Posts

Pages: 1 2 [3] 4 5 6 7 8 ... 10
21
Using Code::Blocks / Re: CB 25.02 - BrowseTracker crash on startup
« Last post by blauzahn on June 24, 2025, 07:59:02 pm »
Thank you Tim,

I always build without precompiled headers.

The actual error from gcc is:

Quote
trunk/src/plugins/contrib/BrowseTracker/JumpTracker.cpp:1313:9: error: 'LogSlot' was not declared in this scope
 1313 |         LogSlot& logslot = pLogMgr->Slot(logIndex);
      |         ^~~~~~~

I found its definition in logmanager.h.

Quote
Should my include statement use quotes instead of <> brackets?
Yes, you are right. Its a project header, not a system header. Is is not done consistently in cb and the plugins though.

Quote
Those variables were actually initialized, but the code got smushed without white space so that cppcheck didn't recognize it.
I re-formated it to cppcheck taste.
Maybe in this case. I did not look it up before posting. Nevertheless there are numerous bad examples still in cb-code. As for BrowseSelector: The two ctors leave parts uninitialized and do not delegate. The default ctor is marked private, implemented but the comment says it is unused. I prefer code that does not pose additional puzzles. If a tool has already spotted an issue and it is not a false positive. Then why should I fire up the debugger and search for spurious errors due to UB.

I actually like having CppCheck (trunk) in addition to gcc, clang, msvc, scan-build, clangd, clang-tidy and the sanitizers.
It is a very well maintained project with constant little improvements. You can get more control over it with:
Code
--inline-suppr --suppress=missingIncludeSystem

I have a largish project, north of 500k SLOC. In that I am usually down to a dozen cppcheck warnings. Granted, the code contains some cppcheck-suppress. Please note: It also contains some NOLINTNEXTLINE. I have enabled many warnings in compiler, cppcheck and clang-tidy. Some warnings might be debatable or not apply to some cases in a codebase. I prefer to not kill warnings globally but document exceptions on a per case base right at the spot in code. Needs judgement but that is a good thing. Recently, cppcheck changed the semantics of paths for #include. At the moment I get numerous missingInclude warnings. Did not yet investigate on that. Slightly annoying, hopefully just temporarily.

Thanks for adding the missing guard against nullptr. I would prefer code where this is not needed in the first place. With old code, you can not avoid it completely. But in newer code I'd at least try to minimize is.

If you are under Linux, I recommend to try scan-build( see https://clang.llvm.org/docs/analyzer/user-docs/CommandLineUsage.html#scan-build).
It reports several bugs in cb.
22
Using Code::Blocks / Re: CB 25.02 - BrowseTracker crash on startup
« Last post by stahta01 on June 24, 2025, 06:56:41 pm »
Hi Pecan,

thank you for the effort.

With the last patch (svn13671 BrowseTracker Move ... ) I get a compile error when building on Linux with make. An include is missing:
Code
#include <logmanager.h>
I don't understand this, logmanager.h is an sdk header, not a BrowseTracker header. It's included in trunk\src\include\Makefile.am Should my include statement use quotes instead of <> brackets?

I build without PCH and just got the same error with the git repo that is updated every 24 hours so it is likely 12 to 36 hours old at most.

So, test with out using PCH and you will likely get the issue.

Tim S.
23
Using Code::Blocks / Re: UI : how to close all sub program at once ?
« Last post by Miguel Gimenez on June 23, 2025, 04:40:53 pm »
Look at Edit -> Folding and Settings -> Editor -> Folding.

You can add shortcuts using Settings -> Editor -> Keyboard shortcuts
24
Using Code::Blocks / UI : how to close all sub program at once ?
« Last post by Mandrake8790 on June 23, 2025, 03:58:50 pm »
Hi,

I want to close at once all the sub programs.
Does it exist a shortcut or an item menu to do that ?

User case (see picture) :
i open several sub programs, so there are a lot of minus signs inside squares.
i want to close them all at once => the result : there are only plus signs

Thanks
25
General (but related to Code::Blocks) / Re: I just start learning C++
« Last post by stahta01 on June 23, 2025, 01:07:10 pm »
Website rules basically Code::Blocks questions are okay; but, programming how to is off topic (OT).

https://forums.codeblocks.org/index.php/topic,9996.0.html
26
General (but related to Code::Blocks) / I just start learning C++
« Last post by Hortudy on June 23, 2025, 09:42:20 am »
Hello,

I'm a newcomer just learning C++ and Code::block seems to be a good soft to learn.

My mane goal is too develop audio plugins, this is why I choose to lear C++.
27
Using Code::Blocks / Re: CB 25.02 - BrowseTracker crash on startup
« Last post by Pecan on June 22, 2025, 10:00:25 pm »
Hi Pecan,

thank you for the effort.

With the last patch (svn13671 BrowseTracker Move ... ) I get a compile error when building on Linux with make. An include is missing:
Code
#include <logmanager.h>
I don't understand this, logmanager.h is an sdk header, not a BrowseTracker header. It's included in trunk\src\include\Makefile.am Should my include statement use quotes instead of <> brackets?

Quote
When scrolling very briefly through the diff I noticed a function with a suspiciously empty if statement. It looks like unintentional semantics:

Code
void JumpTracker::OnLeftUp(wxMouseEvent& event) {
    if (m_leftDown && (not m_isDragging)) {
        // Pure click (no drag) occurred
    }
    m_leftDown = m_isDragging = false;
    event.Skip();
}
I had removed some old code. I added a comment to make it clearer. But cppcheck won't like it anyway.

Rant: I have never gotten cppcheck to work reliably. It spews out vast amounts of error or warning messages even when the compiler or clangd does not.

Quote
When I run CppCheck over the BrowseTracker cb-project, I get several warnings. E.g.:
Quote
BrowseTrackerLayout.cpp:173:41: warning: Either the condition 'cursor' is redundant or there is possible null pointer dereference: cursor. [nullPointerRedundantCheck]
            TiXmlElement* browsemarks = cursor->NextSiblingElement("BrowseMarks");
                                        ^
BrowseTrackerLayout.cpp:155:17: note: Assuming that condition 'cursor' is not redundant
            if (cursor)
                ^
BrowseTrackerLayout.cpp:173:41: note: Null pointer dereference
            TiXmlElement* browsemarks = cursor->NextSiblingElement("BrowseMarks");
                                        ^

or
Quote
BrowseSelector.cpp:93:17: warning: Member variable 'BrowseSelector::m_pBrowseTracker' is not initialized in the constructor. Member variables of native types, pointers, or references are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior. [uninitMemberVarPrivate]
BrowseSelector::BrowseSelector()
                ^
BrowseSelector.cpp:93:17: warning: Member variable 'BrowseSelector::m_menuID' is not initialized in the constructor. Member variables of native types, pointers, or references are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior. [uninitMemberVarPrivate]
BrowseSelector::BrowseSelector()
                ^
BrowseSelector.cpp:93:17: warning: Member variable 'BrowseSelector::m_KeyDownCode' is not initialized in the constructor. Member variables of native types, pointers, or references are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior. [uninitMemberVarPrivate]
BrowseSelector::BrowseSelector()
                ^
BrowseSelector.cpp:93:17: warning: Member variable 'BrowseSelector::m_KeyDownMods' is not initialized in the constructor. Member variables of native types, pointers, or references are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior. [uninitMemberVarPrivate]
BrowseSelector::BrowseSelector()
                ^

Besides other warnings.

Since the topic-starter observed a crash, these should be fixed.

Have a nice day.

Those variables were actually initialized, but the code got smushed without white space so that cppcheck didn't recognize it.
I re-formated it to cppcheck taste.

I've changed the "cursor" statement to guard against use of a nullptr. Thanks.

Thanks for looking at this.
28
Using Code::Blocks / Re: CB 25.02 - BrowseTracker crash on startup
« Last post by blauzahn on June 22, 2025, 10:29:25 am »
Hi Pecan,

thank you for the effort.

With the last patch (svn13671 BrowseTracker Move ... ) I get a compile error when building on Linux with make. An include is missing:
Code
#include <logmanager.h>

When scrolling very briefly through the diff I noticed a function with a suspiciously empty if statement. It looks like unintentional semantics:

Code
void JumpTracker::OnLeftUp(wxMouseEvent& event) {
    if (m_leftDown && (not m_isDragging)) {
        // Pure click (no drag) occurred
    }
    m_leftDown = m_isDragging = false;
    event.Skip();
}

When I run CppCheck over the BrowseTracker cb-project, I get several warnings. E.g.:
Quote
BrowseTrackerLayout.cpp:173:41: warning: Either the condition 'cursor' is redundant or there is possible null pointer dereference: cursor. [nullPointerRedundantCheck]
            TiXmlElement* browsemarks = cursor->NextSiblingElement("BrowseMarks");
                                        ^
BrowseTrackerLayout.cpp:155:17: note: Assuming that condition 'cursor' is not redundant
            if (cursor)
                ^
BrowseTrackerLayout.cpp:173:41: note: Null pointer dereference
            TiXmlElement* browsemarks = cursor->NextSiblingElement("BrowseMarks");
                                        ^

or
Quote
BrowseSelector.cpp:93:17: warning: Member variable 'BrowseSelector::m_pBrowseTracker' is not initialized in the constructor. Member variables of native types, pointers, or references are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior. [uninitMemberVarPrivate]
BrowseSelector::BrowseSelector()
                ^
BrowseSelector.cpp:93:17: warning: Member variable 'BrowseSelector::m_menuID' is not initialized in the constructor. Member variables of native types, pointers, or references are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior. [uninitMemberVarPrivate]
BrowseSelector::BrowseSelector()
                ^
BrowseSelector.cpp:93:17: warning: Member variable 'BrowseSelector::m_KeyDownCode' is not initialized in the constructor. Member variables of native types, pointers, or references are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior. [uninitMemberVarPrivate]
BrowseSelector::BrowseSelector()
                ^
BrowseSelector.cpp:93:17: warning: Member variable 'BrowseSelector::m_KeyDownMods' is not initialized in the constructor. Member variables of native types, pointers, or references are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior. [uninitMemberVarPrivate]
BrowseSelector::BrowseSelector()
                ^

Besides other warnings.

Since the topic-starter observed a crash, these should be fixed.

Have a nice day.
29
Help / Re: Debugging problem in a console application with ncurses library
« Last post by Bug Killer on June 21, 2025, 03:25:31 pm »
It appears that by default C::B runs a console application in a xterm terminal. If xterm is not installed the program is not displayed.

Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: /home/cdf24/Documents/CodeBlocks/nctest/
Adding source dir: /home/cdf24/Documents/CodeBlocks/nctest/
Adding file: /home/cdf24/Documents/CodeBlocks/nctest/bin/Debug/nctest
Changing directory to: /home/cdf24/Documents/CodeBlocks/nctest/.
Set variable: LD_LIBRARY_PATH=.:
Starting debugger: /usr/bin/gdb -nx -fullname -quiet  -args /home/cdf24/Documents/CodeBlocks/nctest/bin/Debug/nctest
Setting SHELL to '/bin/sh'
done
Setting breakpoints
Failed to execute terminal command: 'xterm -T 'Program Console' -e sleep 80012477' (exit code: -1)
Debugger name and version: GNU gdb (AlmaLinux) 14.2-4.el9
At /home/cdf24/Documents/CodeBlocks/nctest/main.cpp:9
Continuing...

You can change the default terminal for gnome-terminal in the drop list.

The message "warning: GDB: Failed to set controlling terminal: Operation not permitted" can be safely ignored.
30
Help / Re: Debugging problem in a console application with ncurses library
« Last post by Krice on June 21, 2025, 12:48:31 pm »
It's even easier if you run gdb from the command line, but you need to copy data files etc. to where the executable file is, if it needs them (or set the working directory from gdb I guess). I can run gdb from command line and debug the program that way, I'm just wondering if it's even possible to debug ncurses programs within Code::Blocks. It has to be some kind of gdb issue, because running without gdb works. It's a mess. I don't know why TERM=xterm removes the error message when running, but doesn't show the executable's console window.
Pages: 1 2 [3] 4 5 6 7 8 ... 10