News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Unable to read source file

Started by LuiZiffer, July 20, 2018, 10:52:15 AM

Previous topic - Next topic

LuiZiffer

Hello there,

I just installed Code::Blocks on OpenSuse Leap 42.3 for Windows Subsystem (Windows 10 installed -> OpenSuse Sub).
I'm using wxWidgets version 3.0.4 nostl.
When I try to open an existing project I get the following error in the terminal:

QuoteNativeParser::DoFullParsing(): AddProjectDefinedMacros failed!
NativeParser::DoFullParsing(): Adding cpp/c files to batch-parser
NativeParser::DoFullParsing(): Added 1 source file(s) for project 'test' to batch-parser...
NativeParser::CreateParser(): Finish creating a new parser for project 'test'
NativeParser::OnParserStart(): Starting batch parsing for project 'test'...
NativeParser::OnParserEnd(): Project 'test' parsing stage done!
Project 'test' parsing stage done (2 total parsed files, 245 tokens in 0 minute(s), 0.003 seconds).
SystemHeadersThread: /usr/include/c++/4.8/ , 4326
SystemHeadersThread: /usr/include/c++/4.8/x86_64-suse-linux/ , 23
SystemHeadersThread: /usr/include/c++/4.8/backward/ , 8
SystemHeadersThread: /usr/lib64/gcc/x86_64-suse-linux/4.8/include/ , 56
SystemHeadersThread: /usr/local/include/ , 162
SystemHeadersThread: /usr/lib64/gcc/x86_64-suse-linux/4.8/include-fixed/ , 3
SystemHeadersThread: /usr/x86_64-suse-linux/include/ , 0
SystemHeadersThread: /usr/include/ , 16359
SystemHeadersThread: Total number of paths: 8
Final encoding detected: Unicode 8 bit (UTF-8) (ID: 43)
Encoding conversion has failed (buffer is empty)!
Something seriously went wrong while converting file content to wxString!

The Project is called "test" and has one source file: main.c. In Code::Blocks main.c only shows an empty file.
I can write and save but closing and opening a file makes the content disappear.
I used cat /path/to/project/main.c, and it displays everything I have written so far.

BlueHazzard

What language do you use? What encoding is the file? Does it also happen if you save it as utf-8 file?

LuiZiffer

file: main.c: text/plain; charset=us-ascii
Language: C/C++
I can save anything i write, but trying to re-open or read a file causes the above error and only shows an empty file

oBFusCATed

What version of codeblocks are you using? Do you see the assert dialog?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

BlueHazzard

QuoteLanguage: C/C++
By language i mean your system language and encoding...
Settings in Settings->Editor->Encoding settings?

LuiZiffer

@oBFusCATed Is this what you meant? (Sry, I'm new to this)
QuoteStarting Code::Blocks Release 17.12  rev 11256 Jul 19 2018, 16:03:43 - wx3.0.4 (Linux, unicode) - 64 bit
Initialize EditColourSet .....
Initialize EditColourSet: done.
Loading menubar...
AStylePlugin: loaded
Abbreviations: loaded
Autosave: loaded
ClassWizard: loaded
CodeCompletion: loaded
Compiler: loaded
Debugger: loaded
FilesExtensionHandler: loaded
OccurrencesHighlighting: loaded
OpenFilesList: loaded
ProjectsImporter: loaded
ScriptedWizard: loaded
ToDoList: loaded
Source code formatter (AStyle) plugin activated
Abbreviations plugin activated
Autosave plugin activated
Class wizard plugin activated
Code completion plugin activated
Added compiler "GNU GCC Compiler"
Added compiler "Intel C/C++ Compiler"
Added compiler "GDC D Compiler"
Added compiler "GNU Fortran Compiler"
Added compiler "G95 Fortran Compiler"
Added compiler "GNU GCC Compiler for ARM"
Added compiler "GNU GCC Compiler for Android"
Added compiler "GNU GCC Compiler for AVR"
Added compiler "GNU GCC Compiler for Blackfin"
Added compiler "LLVM Clang Compiler"
Added compiler "Digital Mars D Compiler"
Added compiler "LLVM D Compiler"
Added compiler "GNU GCC Compiler for LM32"
Added compiler "GNU GCC Compiler for LM8"
Added compiler "GNU GCC Compiler for MSP430 (HighTec)"
Added compiler "*No Compiler*"
Added compiler "PGI Fortran Compiler"
Added compiler "GNU GCC Compiler for PowerPC EABI"
Added compiler "GNU GCC Compiler for PowerPC (HighTec)"
Added compiler "Small Device C Compiler"
Added compiler "Tiny C Compiler"
Added compiler "GNU GCC Compiler for TriCore (HighTec)"
Added compiler "GNU GCC Compiler for ZPU"
Compiler plugin activated
Debugger plugin activated
Files extension handler plugin activated
OccurrencesHighlighting plugin activated
Open files list plugin activated
Foreign projects importer plugin activated
Project wizard added for 'Empty project'
Project wizard added for 'Fortran application'
Project wizard added for 'Fortran library'
Project wizard added for 'Fortran DLL'
Project wizard added for 'Console application'
Project wizard added for 'D application'
Project wizard added for 'FLTK project'
Project wizard added for 'GLFW project'
Project wizard added for 'GLUT project'
Project wizard added for 'GTK+ project'
Project wizard added for 'Irrlicht project'
Project wizard added for 'Java application'
Project wizard added for 'Lightfeather project'
Project wizard added for 'Matlab project'
Project wizard added for 'OpenCV project'
Project wizard added for 'OpenGL project'
Project wizard added for 'Ogre project'
Project wizard added for 'Code::Blocks plugin'
Project wizard added for 'QT4 project'
Project wizard added for 'QT4 (shared) project'
Project wizard added for 'QT5 project'
Project wizard added for 'SDL project'
Project wizard added for 'SDL2 project'
Project wizard added for 'SFML project'
Project wizard added for 'Static library'
Project wizard added for 'Shared library'
Project wizard added for 'wxWidgets project'
Build-target wizard added for 'Console'
Build-target wizard added for 'Static library'
Build-target wizard added for 'wxWidgets'
Project wizard added for 'Arduino Project'
Project wizard added for 'ARM Project'
Project wizard added for 'AVR Project'
Project wizard added for 'MSP430 Project'
Project wizard added for 'TriCore Project'
Project wizard added for 'PowerPC Project'
Project wizard added for 'MCS51 Project'
File(s) wizard added for 'Empty file'
File(s) wizard added for 'C/C++ source'
File(s) wizard added for 'D source'
File(s) wizard added for 'C/C++ header'
File(s) wizard added for 'Fortran source'
File(s) wizard added for 'Java source'
Scripted wizard plugin activated
Todo List plugin activated
Loading toolbar...
Initializing plugins...

Version: 17.12
Encoding when opening files: UTF-8
Encoding: as fallback encoding
Checked: If conversion fails using the settings above, try system locale settings

Language: (i hope this is what you want, as I wrote at the top, I'm new to this) OpenSuse - English, Windows - German
and encoding is UTF-8



Jenna

Can you share a file that can not be opened ?

LuiZiffer

this is a simple hello world. The project can be opened, but when i open main.c the file appears empty.

LuiZiffer

After writing:
Quotechmod 777 test/
I tried again with codeblocks but same result.

The requested output:
Quotetotal 4
drwxrwxrwx 1 luiziffer users  512 Jul 20 09:33 bin
-rwxrwxrwx 1 luiziffer users  101 Jul 21 13:22 main.c
drwxrwxrwx 1 luiziffer users  512 Jul 20 09:33 obj
-rwxrwxrwx 1 luiziffer users 1066 Jul 18 18:49 test.cbp
-rwxrwxrwx 1 luiziffer users  354 Jul 21 13:23 test.layout


BlueHazzard

does i  happen with any text file or only with files you created with codeblocks?
what if you use some other encoding then utf8?
does the same problem arises with the windows exe of codeblocks on the same system, same file?

BlueHazzard

are the layout and project settings saved and restored correctly?
what if you rename the c file to txt file?
do you use some color scheme?
are you sure the file is displayed as empty, or is the text simply white on white? does the cursor move?

LuiZiffer

Quotedoes i  happen with any text file or only with files you created with codeblocks?
Any, regardless of how the file was created.
Quotewhat if you use some other encoding then utf8?
I tried Windows-1252 and default, no changes.
Quotedoes the same problem arises with the windows exe of codeblocks on the same system, same file?
No, the windows version can open any file without issue.
Quoteare the layout and project settings saved and restored correctly?
I'm sorry, I don't know how to determine that.
Quotewhat if you rename the c file to txt file?
No changes.
Quotedo you use some color scheme?
No, everything is set to default. (Didn't change anything yet)
Quoteare you sure the file is displayed as empty, or is the text simply white on white? does the cursor move?
The file is empty -> pics: OpenSuse, Windows 10 (win10)


stahta01

Could the problem be the BOM at the start of the UTF8 file?

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

LuiZiffer

troubleshooting.txt contains the text "testing"

I tried:
Quotevi troubleshooting.txt
:set nobomb
:wq

and,
Quotesed -i $'1s/^\uFEFF//' troubleshooting.txt

without success


BlueHazzard

QuoteI'm sorry, I don't know how to determine that.
Edit the Project->Build options
close the project reopen it and look if the changes are there...


i am out of ideas.... The file encoding seems to be working, but the file reading is the problem... But it can read the XML documents, because otherwise you would not be able to open the project so file access is not the problem...
I have looked into the code and you fail in the
bool EncodingDetector::DetectEncoding(const wxByte* buffer, size_t size, bool convert_to_wxstring)
function...
I am not quite sure what path the code goes...
if (cfgMgr->ReadInt(_T("/default_encoding/use_option"), 0) == 1)
is false, because you are not getting
QuoteWarning: bypassing C::B's auto-detection!
so you go the mozilla detection route. There the first entry is
if (!buffer)
            return false;

so if buffer is a 0 pointer you will never continue, so the pointer is valid...

But later it fails in
bool EncodingDetector::ConvertToWxString(const wxByte* buffer, size_t size)
with
if (!buffer || size == 0)
so there is really something wrong here... More error logging would help. But in the end only debugging can solve this...