Author Topic: Unable to read source file  (Read 2684 times)

Offline LuiZiffer

  • Multiple posting newcomer
  • *
  • Posts: 15
Unable to read source file
« on: July 20, 2018, 10:52:15 am »
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:

Quote
NativeParser::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.

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 2022
Re: Unable to read source file
« Reply #1 on: July 20, 2018, 12:32:51 pm »
What language do you use? What encoding is the file? Does it also happen if you save it as utf-8 file?

Offline LuiZiffer

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Unable to read source file
« Reply #2 on: July 20, 2018, 12:37:29 pm »
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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11128
    • Travis build status
Re: Unable to read source file
« Reply #3 on: July 20, 2018, 07:46:26 pm »
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!]

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 2022
Re: Unable to read source file
« Reply #4 on: July 20, 2018, 09:48:26 pm »
Quote
Language: C/C++
By language i mean your system language and encoding...
Settings in Settings->Editor->Encoding settings?

Offline LuiZiffer

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Unable to read source file
« Reply #5 on: July 21, 2018, 08:53:59 am »
@oBFusCATed Is this what you meant? (Sry, I'm new to this)
Quote
Starting 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



Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7264
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Unable to read source file
« Reply #6 on: July 21, 2018, 11:42:21 am »
Can you share a file that can not be opened ?

Offline LuiZiffer

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Unable to read source file
« Reply #7 on: July 21, 2018, 01:27:16 pm »
this is a simple hello world. The project can be opened, but when i open main.c the file appears empty.

Offline omlk

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Unable to read source file
« Reply #8 on: July 23, 2018, 02:20:51 am »
I assume there may be a problem with access rights to files.

Read this https://www.computerhope.com/unix/uchmod.htm after

Run in console where are main.c and where are files C::B IDE files:
Code: [Select]
ls -l
and post result here

« Last Edit: July 23, 2018, 02:26:05 am by omlk »

Offline LuiZiffer

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Unable to read source file
« Reply #9 on: July 23, 2018, 08:23:01 am »
After writing:
Quote
chmod 777 test/
I tried again with codeblocks but same result.

The requested output:
Quote
total 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


Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 2022
Re: Unable to read source file
« Reply #10 on: July 23, 2018, 10:02:31 am »
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?

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 2022
Re: Unable to read source file
« Reply #11 on: July 23, 2018, 10:05:00 am »
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?

Offline LuiZiffer

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Unable to read source file
« Reply #12 on: July 23, 2018, 10:36:30 am »
Quote
does i  happen with any text file or only with files you created with codeblocks?
   Any, regardless of how the file was created.
Quote
what if you use some other encoding then utf8?
   I tried Windows-1252 and default, no changes.
Quote
does 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.
Quote
are the layout and project settings saved and restored correctly?
   I'm sorry, I don't know how to determine that.
Quote
what if you rename the c file to txt file?
   No changes.
Quote
do you use some color scheme?
   No, everything is set to default. (Didn't change anything yet)
Quote
are 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)


Offline stahta01

  • Lives here!
  • ****
  • Posts: 6310
    • My Best Post
Re: Unable to read source file
« Reply #13 on: July 23, 2018, 10:37:53 am »
Could the problem be the BOM at the start of the UTF8 file?

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

Offline LuiZiffer

  • Multiple posting newcomer
  • *
  • Posts: 15
Re: Unable to read source file
« Reply #14 on: July 23, 2018, 10:45:38 am »
troubleshooting.txt contains the text "testing"

I tried:
Quote
vi troubleshooting.txt
:set nobomb
:wq

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

without success