Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling on GCC, 64 bit Ubuntu #8

Open
stuaxo opened this issue Nov 17, 2014 · 2 comments
Open

Compiling on GCC, 64 bit Ubuntu #8

stuaxo opened this issue Nov 17, 2014 · 2 comments

Comments

@stuaxo
Copy link

stuaxo commented Nov 17, 2014

I got the following error compiling

 stu  beezlebub  ~  projects  external  three_cpp  build  master  $ make
Scanning dependencies of target three
[  4%] Building CXX object CMakeFiles/three.dir/three/impl/src.cpp.o
[  9%] Building CXX object CMakeFiles/three.dir/three/impl/src_extras.cpp.o
In file included from /home/stu/projects/external/three_cpp/./three/impl/src_extras.hpp:12:0,
                 from /home/stu/projects/external/three_cpp/three/impl/src_extras.cpp:2:
/home/stu/projects/external/three_cpp/./three/extras/utils/impl/font.ipp: In function ‘std::vector<unsigned char> three::detail::load(const string&)’:
/home/stu/projects/external/three_cpp/./three/extras/utils/impl/font.ipp:29:38: error: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Werror=unused-result]
   fread( buffer.data(), 1, size, fp );
                                      ^
compilation terminated due to -Wfatal-errors.
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/three.dir/three/impl/src_extras.cpp.o] Error 1
make[1]: *** [CMakeFiles/three.dir/all] Error 2
make: *** [all] Error 2

This patch fixes it, but it's probably a workaround - either the warning should be disabled, or probably add some code that does something better in the error state (not sure what threejs does if you try and load a font thats not available).

diff --git a/three/extras/utils/impl/font.ipp b/three/extras/utils/impl/font.ipp
index 3626724..9683e79 100644
--- a/three/extras/utils/impl/font.ipp
+++ b/three/extras/utils/impl/font.ipp
@@ -26,7 +26,10 @@ inline std::vector<unsigned char> load( const std::string& file ) {
   fseek( fp, 0, SEEK_SET );

   std::vector<unsigned char> buffer( size );
-  fread( buffer.data(), 1, size, fp );
+  int sizeRead = fread( buffer.data(), 1, size, fp );
+  if (sizeRead != size) {
+      printf("Error loading font");
+  }
   fclose( fp );
   return buffer;
 }
@@ -244,4 +247,4 @@ const Texture::Ptr& Font::texture() const {

 } // namespace three

-#endif // THREE_FONT2_IPP
\ No newline at end of file
+#endif // THREE_FONT2_IPP
@jdduke
Copy link
Owner

jdduke commented Nov 24, 2014

Thanks for the report @stuaxo, might I ask which compiler (including its version) you're using?

@stuaxo
Copy link
Author

stuaxo commented Nov 24, 2014

Hi,
It's GCC, 4.8.2

$ gcc --version
gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants