Recent Posts

Pages: 1 2 [3] 4 5 6 7 8 ... 10
21
Help / Re: [SOLVED] Squirrel Build Script Syntax Error: expected 'IDENTIFIER'
« Last post by The_GTA on January 18, 2022, 11:15:21 pm »
I am sorry. (...)

Name             : Code::Blocks
Version          : 20.03-r11997
(...)
Don't worry about it. The issue has been solved. You seem to be using an old version of Code::Blocks which does not have the "base" keyword in Squirrel yet.

I find it interesting that you want to investigate the Squirrel VM. To me the CB Squirrel build script system is a great means to fully configure my program building pipeline. It is a novel feature which no other IDE build system has, in that form. Other build systems rely on the terribly antiquated makefile concept which I dislike for it's unhealthy gimmicks (no spaces in paths possible, stuff has to be written in rules, etc). In stark contrast for the Squirrel case, you have got the full freedom of a scripting language which feels really nice. I give the Visual Studio .vcxproj makefile system some slack because it is XML based thus has a really stable format.
22
Help / Re: Linux allows removal of open files.
« Last post by jordi on January 18, 2022, 10:01:32 pm »
23
Help / Re: [SOLVED] Squirrel Build Script Syntax Error: expected 'IDENTIFIER'
« Last post by jordi on January 18, 2022, 09:51:24 pm »
I am sorry. I don't have any squirrel build script .  Maybe can help you to see the RegisterBinding funcion in scriptingbindings.cpp file.  There are defined all the bindings to: codeblocks code, wxWidgets types, constants, etc
I can try to help you whether you have any doubt. I want to review how squirrel virtual machine works and how bindings are done.

To reproduce the issue I have had to change "base" by "function" as parameter in my system: Debian GNU/Linux 11  (info below):
Then, "base" was not a keyword.  I'll review it

Name             : Code::Blocks
Version          : 20.03-r11997
SDK Version      : 2.0.0
Scintilla Version: 3.7.5
Author           : The Code::Blocks Team
E-mail           : info@codeblocks.org
Website          : http://www.codeblocks.org

wxWidgets Library (wxGTK port)
Version 3.0.5 (Unicode: wchar_t, debug level: 1),
Runtime version of toolkit used is 3.24.
Compile-time GTK+ version is 3.24.20.
24
Plugins development / Re: Code completion using LSP and clangd
« Last post by Pecan on January 18, 2022, 08:54:19 pm »
I see there are some code snippet like:

Code
m_MutexInputBufGuard.Lock;

m_MutexInputBufGuard.Unlock();

But in the code, we have to carefully handle the unlocking the wxMutex when return the function body, especially when there are multiply returns.

Is it possible to use the wxMutexLocker, and check the IsOK() function for checking whether it get locked or not.

There are only 2 locks in the code that can cause any trouble. The lock on the input buffer. One to write to the buffer, and one to get the next clangd response out of the buffer. And neither affect the UI thread.

I tried wxMutexLocker first before giving up on it.
I want to be able to unlock the input buffer and then do more work in the function.
When I unlocked the mutex before the function ended,  wxWidgets gave me errors about the mutex. I lost confidence that I could mix a wxMutexLocker and manual unlocks.

In fact, I removed all locks on the main UI thread and used idle time callbacks instead.
25
Plugins development / Re: Code completion using LSP and clangd
« Last post by Pecan on January 18, 2022, 08:30:01 pm »
I see there are many pch files in the folder such as:

C:\Users\[myusername]\AppData\Local\Temp\preamble-c7460b.pch

I think those files is created by clangd, and are there any way to automatically delete them when exit C::B?

EDIT:

clangd writes too much disk : CPP-19402

This discussion looks like the pch can keep in "memory". :)

Here is the patch to fix this pch file issue:

Code
 clangd_client/src/LSPclient/src/client.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/clangd_client/src/LSPclient/src/client.cpp b/clangd_client/src/LSPclient/src/client.cpp
index 88f5f8f..f6b5eb9 100644
--- a/clangd_client/src/LSPclient/src/client.cpp
+++ b/clangd_client/src/LSPclient/src/client.cpp
@@ -266,6 +266,10 @@ ProcessLanguageClient::ProcessLanguageClient(const cbProject* pProject, const ch
 
     command += " --limit-results=20";              // Limit the number of results returned by clangd. 0 means no limit (default=100)
 
+    // clangd writes too much disk : CPP-19402 https://youtrack.jetbrains.com/issue/CPP-19402
+    // "-pch-storage=memory"
+    command += " -pch-storage=memory";
+
     if (wxDirExists(clangResourceDir))
         command += " --resource-dir=" + clangResourceDir;  // Directory for system includes
 

Thanks for that.

I've added code to remove preamble-*.tmp and preamble-*.pch files when the project closes.

I'll later add an option to keep the .pch in memory. (For me, I'd rather keep them on disk and remove them at project close time).

As an aside: Windows does not allow me to remove files that are open and being used. But Linux does. Do you know of a way to tell Linux NOT to allow me to delete open files?
26
Plugins development / Re: Code completion using LSP and clangd
« Last post by Pecan on January 18, 2022, 08:23:19 pm »
I see some error message comes from this function call, but I'm not sure why, this happens when I'm editing source file in the C::B editor.

Code
int ProcessLanguageClient::ReadLSPinputLength()
// ----------------------------------------------------------------------------
{
    // this function is driven by readJson() via the thread in transport::loop()
    // and the incoming data is locked.
    // thread was started in constructor and called from readJason() after locking the buffer

    // "Content-Length: <digits>\r\n\r\n"

    if (Has_LSPServerProcess() and m_std_LSP_IncomingStr.length())
    {
        // search for LSP header
        size_t hdrPosn = m_std_LSP_IncomingStr.find("Content-Length: ");
        if (hdrPosn == std::string::npos)
            return wxNOT_FOUND;
        else //have incoming text
        {
            if (hdrPosn != 0)   // verify LSP header is at beginning of buffer
            {
                // Error: header is not at beginning of buffer. Try to fix it.
                // usually caused by clangd invalid utf8 sequence
                wxString msg(wxString::Format("ERROR:%s(): buffLength (%d): Position of content header %d.\n",
                             __FUNCTION__, int(m_std_LSP_IncomingStr.length()), int(hdrPosn)) );
                msg += "Buffer contents written to client log.";
                #if defined(cb_DEBUG)
                    wxSafeShowMessage("Input Buffer error",msg);
                #endif
                msg += "LSP_IncomingStrBuf:\n" + m_std_LSP_IncomingStr + "\n";
                writeClientLog(msg);
                // adjust the data buf to get clangd header at buff beginning
                m_std_LSP_IncomingStr = m_std_LSP_IncomingStr.substr(hdrPosn);
            }

I just enabled the log file, and see the log message(in C:\Users\[myusername]\AppData\Local\Temp\CBclangd_client-1332.log

And the content of the log file are:

Code
19:45:09.758 ERROR:ReadLSPinputLength(): buffLength (549): Position of content header 112.
Buffer contents written to client log.LSP_IncomingStrBuf:
":{"newText":"wxConvAuto($0)","range":{"end":{"character":16,"line":94},"start":{"character":12,"line":94}}}}]}}Content-Length: 414



{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"category":"Parse Issue","code":"expected_unqualified_id","codeActions":[],"message":"Expected unqualified-id","range":{"end":{"character":14,"line":97},"start":{"character":12,"line":97}},"relatedInformation":[],"severity":1,"source":"clang"}],"uri":"file:///F:/test/Config.cpp","version":1}}

This is caused by clangd sending a message (usually a code completion response) with an illegal utf8 char. Clangd sets the message with a header specifying the wrong length which eats up the content-header for the following message.


I have to correct the situation by searching for the content-header.
I have now commented out that message box. The code works to correct the situation so we don't need that anymore.

Thanks for testing and finding these "gotchas" I've forgotten about.
27
Help / Linux allows removal of open files.
« Last post by Pecan on January 18, 2022, 07:29:30 pm »
I'm trying to remove the temporary files left by clangd.
But I don't want to delete the logs and temp files that are currently open.

Linux is allowing me to "rm" files that are open and being used. Windows (thankfully) doesn't allow this.

What do I need to do on Linux to get it to disallow removal of open/active files?
28
Using Code::Blocks / Re: Can't add X11 to search directory
« Last post by sodev on January 18, 2022, 05:41:48 pm »
I have only quite limited Flatpak experience, for the single application i'm building for Flatpak i didn't need to read the footnotes. I'm afraid for CodeBlocks the footnotes do apply: Sandbox Permissions. So on second thought, looks like it's kind of impossible to create a general purpose CodeBlocks Flatpak, due to the path conflicts you need major adaptions of the project to access libraries of the host. Sorry for the misinformation.

However, a possible Flatpak scenario could be to create very specific distributions that contain all required libraries for a specific use case. This way you don't have to pollute the host with such libraries, you could use fixed versions different from the host and the user doesn't need to setup his system to use them. Looking at you, school teachers and the like ;).
29
Plugins development / Re: Code completion using LSP and clangd
« Last post by ollydbg on January 18, 2022, 12:35:08 pm »
I see there are some code snippet like:

Code
m_MutexInputBufGuard.Lock;

m_MutexInputBufGuard.Unlock();

But in the code, we have to carefully handle the unlocking the wxMutex when return the function body, especially when there are multiply returns.

Is it possible to use the wxMutexLocker, and check the IsOK() function for checking whether it get locked or not.
30
Help / Re: Codeblocks long startup time
« Last post by Miguel Gimenez on January 18, 2022, 11:12:33 am »
We have discussed this already, please see r12661 that includes your proposed changes to options_gcc.xml
Pages: 1 2 [3] 4 5 6 7 8 ... 10