Search Results

Search found 1632 results on 66 pages for 'cpp'.

Page 19/66 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • GCC problem with raw double type comparisons

    - by Monomer
    I have the following bit of code, however when compiling it with GCC 4.4 with various optimization flags I get some unexpected results when its run. #include <iostream> int main() { const unsigned int cnt = 10; double lst[cnt] = { 0.0 }; const double v[4] = { 131.313, 737.373, 979.797, 731.137 }; for(unsigned int i = 0; i < cnt; ++i) { lst[i] = v[i % 4] * i; } for(unsigned int i = 0; i < cnt; ++i) { double d = v[i % 4] * i; if(lst[i] != d) { std::cout << "error @ : " << i << std::endl; return 1; } } return 0; } when compiled with: "g++ -pedantic -Wall -Werror -O1 -o test test.cpp" I get the following output: "error @ : 3" when compiled with: "g++ -pedantic -Wall -Werror -O2 -o test test.cpp" I get the following output: "error @ : 3" when compiled with: "g++ -pedantic -Wall -Werror -O3 -o test test.cpp" I get no errors when compiled with: "g++ -pedantic -Wall -Werror -o test test.cpp" I get no errors I do not believe this to be an issue related to rounding, or epsilon difference in the comparison. I've tried this with Intel v10 and MSVC 9.0 and they all seem to work as expected. I believe this should be nothing more than a bitwise compare. If I replace the if-statement with the following: if (static_cast<long long int>(lst[i]) != static_cast<long long int>(d)), and add "-Wno-long-long" I get no errors in any of the optimization modes when run. If I add std::cout << d << std::endl; before the "return 1", I get no errors in any of the optimization modes when run. Is this a bug in my code, or is there something wrong with GCC and the way it handles the double type?

    Read the article

  • How to get path from a variable

    - by yoshco
    Following http://stackoverflow.com/questions/659647/how-to-get-folder-path-from-file-path-with-cmd I want to strip the path (without the filename) from a variable. following the logic of the methods discussed above I would like to use batch bellow, which doesn't work. any takers? possible? set cpp="C:\temp\lib.dll" echo %cpp% "C:\temp\lib.dll" echo %~dpcpp "C:\temp\" > doesn't work

    Read the article

  • PKCS#7 Signed Code Image extracting

    - by sid
    Hi, I wanted to extract the Signer Informations from PKCS#7 Signed Code Image using C/CPP. I wanted to know the openssl API's. I am Able to extract Using bouncy castle (CMSSignedData). Please let me know the openssl API's which I can use in C/CPP to extract the each signers and signer informations and verify the Signers. is there any API like X509_LOOKUP_buffer() instead of X509_LOOKUP_file() ??? Thanks in advance opensid

    Read the article

  • compiling maya (3d application ) with qt

    - by knishua
    including the maya ( 3d application ) classes in qt program gives lot of errors..... i have added all required include paths and libs...the same problem persists .... this is pro file for my qt project TARGET = FileCon TEMPLATE = app SOURCES += main.cpp \ dialog.cpp HEADERS += dialog.h \ ConvertFunction.h FORMS += dialog.ui LIBS += "C:/Program Files/Autodesk/Maya2008/lib" \ -lOpenMaya.lib \ -lFoundation.lib \ -lOpenMayalib INCLUDEPATH += "C:/Program Files/Autodesk/Maya2008/include" DEFINES = _BOOL \ WIN32 \ REQUIRE_IOSTREAM /////////////////////////////////////////// How is it possible to use maya classes with qt.

    Read the article

  • Does it should be in a namespace?

    - by Knowing me knowing you
    Do I have to put code from .cpp in a namespace from corresponding .h or it's enough to just write using declaration? //file .h namespace a { /*interface*/ class my { }; } //file .cpp using a::my; // Can I just write in this file this declaration and // after that start to write implementation, or // should I write: namespace a //everything in a namespace now { //Implementation goes here } Thanks.

    Read the article

  • Makefile patsubs double replacement

    - by aaa
    hello. is a possible to do something like this, without shell command: CXX_MODULES += $(patsubst %, %/%.cpp, $(LIBRARIES)) notice double replacement which does not work (only first replacement happens) after some tinkering I came up with $(join $(LIBRARIES), $(patsubst %, /%.cpp, $(LIBRARIES))) Thank you

    Read the article

  • Deriving a class from an abstract class (C++)

    - by cemregoksu
    I have an abstract class with a pure virtual function f() and i want to create a class inherited from that class, and also override function f(). I seperated the header file and the cpp file. I declared the function f(int) in the header file and the definition is in the cpp file. However, the compiler says the derived class is still abstract. How can i fix it?

    Read the article

  • undefined reference errors in C++

    - by Phenom
    I have files Record.h and Record.cpp. When I just include the Record.h file, I get several undefined reference errors to functions defined in those files. When I also include Record.cpp then the errors go away. Why is that? Record.h has the forward declarations for the functions it says are an undefined reference.

    Read the article

  • Using the same variable across multiple files in C++

    - by Sam152
    In the process of changing some code, I have spilt some functions into multiple files. I have the files controls.cpp and display.cpp and I would like to be able to have access to the same set of variables in both files. I don't mind where they are initialized or declared, as long as the functions in both files can use them. This was not an issue when the functions were in the same file, but now it seems almost impossible after an hour of googling and trying various things.

    Read the article

  • best alternative to in-definition initialization of static class members? (for SVN keywords)

    - by Jeff
    I'm storing expanded SVN keyword literals for .cpp files in 'static char const *const' class members and want to store the .h descriptions as similarly as possible. In short, I need to guarantee single instantiation of a static member (presumably in a .cpp file) to an auto-generated non-integer literal living in a potentially shared .h file. Unfortunately the language makes no attempt to resolve multiple instantiations resulting from assignments made outside class definitions and explicitly forbids non-integer inits inside class definitions. My best attempt (using static-wrapping internal classes) is not too dirty, but I'd really like to do better. Does anyone have a way to template the wrapper below or have an altogether superior approach? // Foo.h: class with .h/.cpp SVN info stored and logged statically class Foo { static Logger const verLog; struct hInfoWrap; public: static hInfoWrap const hInfo; static char const *const cInfo; }; // Would like to eliminate this per-class boilerplate. struct Foo::hInfoWrap { hInfoWrapper() : text("$Id$") { } char const *const text; }; ... // Foo.cpp: static inits called here Foo::hInfoWrap const Foo::hInfo; char const *const Foo::cInfo = "$Id$"; Logger const Foo::verLog(Foo::cInfo, Foo::hInfo.text); ... // Helper.h: output on construction, with no subsequent activity or stored fields class Logger { Logger(char const *info1, char const *info2) { cout << info0 << endl << info1 << endl; } }; Is there a way to get around the static linkage address issue for templating the hInfoWrap class on string literals? Extern char pointers assigned outside class definitions are linguistically valid but fail in essentially the same manner as direct member initializations. I get why the language shirks the whole resolution issue, but it'd be very convenient if an inverted extern member qualifier were provided, where the definition code was visible in class definitions to any caller but only actually invoked at the point of a single special declaration elsewhere. Anyway, I digress. What's the best solution for the language we've got, template or otherwise? Thanks!

    Read the article

  • How do I get a array to just count how many numbers there are instead of counting the value of each number?

    - by Chad Loos
    //This is the output of the program *** start of 276 2D Arrays_03.cpp program *** Number Count Total 1 3 3 2 6 9 3 15 24 4 6 30 5 9 39 *** end of 276 2D Arrays_03.cpp program *** #include <iostream> #include <string> #include <iomanip> using namespace std; const int COLUMN_SIZE = 13; int main(void) { const int ROW_SIZE = 3; const int COUNT_SIZE = 5; void countValues(const int[][COLUMN_SIZE], const int, int[]); void display(const int [], const int); int numbers[ROW_SIZE][COLUMN_SIZE] = {{1, 3, 4, 5, 3, 2, 3, 5, 3, 4, 5, 3, 2}, {2, 1, 3, 4, 5, 3, 2, 3, 5, 3, 4, 5, 3}, {3, 4, 5, 3, 2, 1, 3, 4, 5, 3, 2, 3, 5}}; int counts[COUNT_SIZE] = {0}; string choice; cout << "*** start of 276 2D Arrays_03.cpp program ***" << endl; cout << endl; countValues(numbers, ROW_SIZE, counts); display(counts, COUNT_SIZE); cout << endl; cout << endl; cout << "*** end of 276 2D Arrays_03.cpp program ***" << endl << endl; cin.get(); return 0; } // end main() This is the function where I need to count each of the values. I know how to sum rows and cols, but I'm not quite sure of the code to just tally the values themselves. void countValues(const int numbers[][COLUMN_SIZE], const int ROW_SIZE, int counts[]) This is what I have so far. { for (int index = 0; index < ROW_SIZE; index++) counts[index]; {

    Read the article

  • Include Obj-C++ header from C++ source file

    - by Schwitzgabel
    Consider the followng situation: MacFont.h struct MacFont : Font { // ... NSFont* font; }; MacFont will be implemented in MacFont.mm FontEngine.cpp: #if defined(OS_MAC) #include "MacFont.h" #elif // ... #endif //... In order to make it compiling, I should rename FontEngine.cpp to FontEngine.mm but I'm not allowed to. So what now?

    Read the article

  • Should it be in a namespace?

    - by Knowing me knowing you
    Do I have to put code from .cpp in a namespace from corresponding .h or it's enough to just write using declaration? //file .h namespace a { /*interface*/ class my { }; } //file .cpp using a::my; // Can I just write in this file this declaration and // after that start to write implementation, or // should I write: namespace a //everything in a namespace now { //Implementation goes here } Thanks.

    Read the article

  • CMake with include and source paths - basic setup

    - by user912403
    I'm trying to set up a test project looking like my own project just to get things working first and it looks like this: /MainProject/inc/main.h /MainProject/src/main.cpp /LibProject/inc/test.h /LibProject/src/test.cpp I've found some tutorials, but I cant find out how to set up this when I have the inc and src folder? How would the CMakeLists.txt files look? Would I have one in /, one in each of the project folders? It seems like I dont need to have one in the inc and src folders?

    Read the article

  • compiling Boost linked libraries (Ubuntu)

    - by Adam Greenhall
    I installed Boost via sudo apt-get install libboost-all-dev on the most recent version of Ubuntu. Now I want to compile a project that uses the Boost.Serialization library, which needs to be linked. I've tried many variants of the following, without success: gcc -I /usr/lib code.cpp -o compiled /usr/lib/libboost_serialization.a and gcc -I /usr/lib code.cpp -o compiled -l libboost_serialization The error message is: error: ‘split_member’ is not a member of ‘boost::serialization ` What am I missing?

    Read the article

  • How to fix Ogre3d segfault with std::_Rb_tree_insert_and_rebalance ?

    - by Balázs Béla
    Hello all. I'm working on a 3d music visualizer using Ogre3d, basically it's a spectrum analizer, a lot like the old xmms plugin: (http)://www.youtube.com/watch?v=_6NKBiwYN24 It works well, the bars are drawn and updated, there are no framerate issues, but it crashes randomly. Sometimes it can run without problems, finish the song, other times it crashes instantly, other times the music just stops, without a crash. Here is the source code for the main class : https://github.com/balazsbela/OgreVisualizer/blob/master/src/VisualizerApplication.cpp#L221 Also the crashes seem to happen less often when I display the framerate overlay from Ogre samples. Would limiting the framerate help ? The crashes are seemingly random. Is it a performance issue ? Please help me out, I'm quite lost on this one, I also posted on Ogre3d forums but I received no responses. (http)://www.ogre3d.org/forums/viewtopic.php?f=2&t=63207 I also tried stackoverflow: (http)://stackoverflow.com/questions/5050147/how-to-fix-ogre3d-segfault-with-std-rb-tree-insert-and-rebalance Thank you. Backtrace: balazsbela@darknet:~/workspace/OgreVisualizer/Release$ gdb OgreVisualizer core GNU gdb (GDB) 7.2-debian Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i486-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /home/balazsbela/workspace/OgreVisualizer/Release/OgreVisualizer...done. [New Thread 17705] [New Thread 17702] [New Thread 17703] [New Thread 17700] Reading symbols from /usr/lib/libv4l/v4l1compat.so...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libv4l/v4l1compat.so Reading symbols from /usr/local/lib/libOgreMain.so.1.7.1...done. Loaded symbols for /usr/local/lib/libOgreMain.so.1.7.1 Reading symbols from /usr/lib/libfftw3.so.3...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libfftw3.so.3 Reading symbols from /usr/lib/libSDL_sound-1.0.so.1...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libSDL_sound-1.0.so.1 Reading symbols from /usr/lib/libSDL-1.2.so.0...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libSDL-1.2.so.0 Reading symbols from /usr/lib/libSDL_mixer-1.2.so.0...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libSDL_mixer-1.2.so.0 Reading symbols from /usr/lib/libOIS-1.2.0.so...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libOIS-1.2.0.so Reading symbols from /usr/lib/libstdc++.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libstdc++.so.6 Reading symbols from /lib/i686/cmov/libm.so.6...Reading symbols from /usr/lib/debug/lib/i686/cmov/libm-2.11.2.so...done. done. Loaded symbols for /lib/i686/cmov/libm.so.6 Reading symbols from /lib/libgcc_s.so.1...(no debugging symbols found)...done. Loaded symbols for /lib/libgcc_s.so.1 Reading symbols from /lib/i686/cmov/libc.so.6...Reading symbols from /usr/lib/debug/lib/i686/cmov/libc-2.11.2.so...done. done. Loaded symbols for /lib/i686/cmov/libc.so.6 Reading symbols from /lib/i686/cmov/libpthread.so.0...Reading symbols from /usr/lib/debug/lib/i686/cmov/libpthread-2.11.2.so...done. done. Loaded symbols for /lib/i686/cmov/libpthread.so.0 Reading symbols from /usr/local/lib/libv4l1.so.0...done. Loaded symbols for /usr/local/lib/libv4l1.so.0 Reading symbols from /usr/lib/libfreetype.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libfreetype.so.6 Reading symbols from /usr/lib/libSM.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libSM.so.6 Reading symbols from /usr/lib/libICE.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libICE.so.6 Reading symbols from /usr/lib/libX11.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libX11.so.6 Reading symbols from /usr/lib/libXext.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libXext.so.6 Reading symbols from /usr/lib/libXt.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libXt.so.6 Reading symbols from /usr/lib/libXaw.so.7...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libXaw.so.7 Reading symbols from /lib/i686/cmov/libdl.so.2...Reading symbols from /usr/lib/debug/lib/i686/cmov/libdl-2.11.2.so...done. done. Loaded symbols for /lib/i686/cmov/libdl.so.2 Reading symbols from /usr/lib/libboost_thread.so.1.42.0...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libboost_thread.so.1.42.0 Reading symbols from /usr/lib/libboost_date_time.so.1.42.0...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libboost_date_time.so.1.42.0 Reading symbols from /usr/lib/libfreeimage.so.3...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libfreeimage.so.3 Reading symbols from /usr/lib/libzzip-0.so.13...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libzzip-0.so.13 Reading symbols from /usr/lib/libz.so.1...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libz.so.1 Reading symbols from /usr/lib/libsmpeg-0.4.so.0...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libsmpeg-0.4.so.0 Reading symbols from /usr/lib/libmikmod.so.2...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libmikmod.so.2 Reading symbols from /usr/lib/libvorbis.so.0...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libvorbis.so.0 Reading symbols from /usr/lib/libvorbisfile.so.3...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libvorbisfile.so.3 Reading symbols from /usr/lib/libFLAC.so.8...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libFLAC.so.8 Reading symbols from /usr/lib/libogg.so.0...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libogg.so.0 Reading symbols from /usr/lib/sse2/libspeex.so.1...(no debugging symbols found)...done. Loaded symbols for /usr/lib/sse2/libspeex.so.1 Reading symbols from /usr/lib/libasound.so.2...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libasound.so.2 Reading symbols from /lib/i686/cmov/librt.so.1...Reading symbols from /usr/lib/debug/lib/i686/cmov/librt-2.11.2.so...done. done. Loaded symbols for /lib/i686/cmov/librt.so.1 Reading symbols from /usr/lib/libdirectfb-1.2.so.9...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libdirectfb-1.2.so.9 Reading symbols from /usr/lib/libfusion-1.2.so.9...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libfusion-1.2.so.9 Reading symbols from /usr/lib/libdirect-1.2.so.9...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libdirect-1.2.so.9 Reading symbols from /usr/lib/libvga.so.1...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libvga.so.1 Reading symbols from /lib/ld-linux.so.2...Reading symbols from /usr/lib/debug/lib/ld-2.11.2.so...done. done. Loaded symbols for /lib/ld-linux.so.2 Reading symbols from /usr/local/lib/libv4l2.so.0...done. Loaded symbols for /usr/local/lib/libv4l2.so.0 Reading symbols from /lib/libuuid.so.1...(no debugging symbols found)...done. Loaded symbols for /lib/libuuid.so.1 Reading symbols from /usr/lib/libxcb.so.1...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libxcb.so.1 Reading symbols from /usr/lib/libXmu.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libXmu.so.6 Reading symbols from /usr/lib/libXpm.so.4...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libXpm.so.4 Reading symbols from /usr/lib/libjpeg.so.62...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libjpeg.so.62 Reading symbols from /usr/lib/libmng.so.1...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libmng.so.1 Reading symbols from /usr/lib/libopenjpeg.so.2...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libopenjpeg.so.2 Reading symbols from /lib/libpng12.so.0...(no debugging symbols found)...done. Loaded symbols for /lib/libpng12.so.0 Reading symbols from /usr/lib/libIlmImf.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libIlmImf.so.6 Reading symbols from /usr/lib/libImath.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libImath.so.6 Reading symbols from /usr/lib/libHalf.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libHalf.so.6 Reading symbols from /usr/lib/libIex.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libIex.so.6 Reading symbols from /usr/lib/libIlmThread.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libIlmThread.so.6 Reading symbols from /lib/libx86.so.1...(no debugging symbols found)...done. Loaded symbols for /lib/libx86.so.1 Reading symbols from /usr/local/lib/libv4lconvert.so.0...done. Loaded symbols for /usr/local/lib/libv4lconvert.so.0 Reading symbols from /usr/lib/libXau.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libXau.so.6 Reading symbols from /usr/lib/libXdmcp.so.6...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libXdmcp.so.6 Reading symbols from /usr/lib/liblcms.so.1...(no debugging symbols found)...done. Loaded symbols for /usr/lib/liblcms.so.1 Reading symbols from /usr/local/lib/OGRE/RenderSystem_GL.so...done. Loaded symbols for /usr/local/lib/OGRE/RenderSystem_GL.so Reading symbols from /usr/lib/libGLU.so.1...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libGLU.so.1 Reading symbols from /usr/lib/libGL.so.1...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libGL.so.1 Reading symbols from /usr/lib/libXrandr.so.2...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libXrandr.so.2 Reading symbols from /usr/lib/libGLcore.so.1...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libGLcore.so.1 Reading symbols from /usr/lib/tls/libnvidia-tls.so.1...(no debugging symbols found)...done. Loaded symbols for /usr/lib/tls/libnvidia-tls.so.1 Reading symbols from /usr/lib/libXrender.so.1...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libXrender.so.1 Reading symbols from /usr/lib/libXcursor.so.1...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libXcursor.so.1 Reading symbols from /usr/lib/libXfixes.so.3...(no debugging symbols found)...done. Loaded symbols for /usr/lib/libXfixes.so.3 Reading symbols from /lib/i686/cmov/libnss_compat.so.2...Reading symbols from /usr/lib/debug/lib/i686/cmov/libnss_compat-2.11.2.so...done. done. Loaded symbols for /lib/i686/cmov/libnss_compat.so.2 Reading symbols from /lib/i686/cmov/libnsl.so.1...Reading symbols from /usr/lib/debug/lib/i686/cmov/libnsl-2.11.2.so...done. done. Loaded symbols for /lib/i686/cmov/libnsl.so.1 Reading symbols from /lib/i686/cmov/libnss_nis.so.2...Reading symbols from /usr/lib/debug/lib/i686/cmov/libnss_nis-2.11.2.so...done. done. Loaded symbols for /lib/i686/cmov/libnss_nis.so.2 Reading symbols from /lib/i686/cmov/libnss_files.so.2...Reading symbols from /usr/lib/debug/lib/i686/cmov/libnss_files-2.11.2.so...done. done. Loaded symbols for /lib/i686/cmov/libnss_files.so.2 Reading symbols from /usr/lib/alsa-lib/libasound_module_rate_speexrate.so...(no debugging symbols found)...done. Loaded symbols for /usr/lib/alsa-lib/libasound_module_rate_speexrate.so Reading symbols from /usr/lib/sse2/libspeexdsp.so.1...(no debugging symbols found)...done. Loaded symbols for /usr/lib/sse2/libspeexdsp.so.1 Core was generated by `./OgreVisualizer'. Program terminated with signal 11, Segmentation fault. #0 0xb6dc563d in std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&) () from /usr/lib/libstdc++.so.6 (gdb) bt #0 0xb6dc563d in std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&) () from /usr/lib/libstdc++.so.6 #1 0xb73bb3c2 in std::_Rb_tree<Ogre::Node*, Ogre::Node*, std::_Identity<Ogre::Node*>, std::less<Ogre::Node*>, Ogre::STLAllocator<Ogre::Node*, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >::_M_insert_(std::_Rb_tree_node_base const*, std::_Rb_tree_node_base const*, Ogre::Node* const&) () from /usr/local/lib/libOgreMain.so.1.7.1 #2 0xb73b5a52 in _M_insert_unique (this=0xb6157ea0, child=0xb616aff8, forceParentUpdate=false) at /usr/include/c++/4.4/bits/stl_tree.h:1182 #3 insert (this=0xb6157ea0, child=0xb616aff8, forceParentUpdate=false) at /usr/include/c++/4.4/bits/stl_set.h:411 #4 Ogre::Node::requestUpdate (this=0xb6157ea0, child=0xb616aff8, forceParentUpdate=false) at /home/balazsbela/Downloads/ogre_src_v1-7-1/OgreMain/src/OgreNode.cpp:805 #5 0xb73b6a40 in Ogre::Node::needUpdate (this=0xb616aff8, forceParentUpdate=92) at /home/balazsbela/Downloads/ogre_src_v1-7-1/OgreMain/src/OgreNode.cpp:789 #6 0xb73b5038 in Ogre::Node::setScale (this=0x1825c, scale=...) at /home/balazsbela/Downloads/ogre_src_v1-7-1/OgreMain/src/OgreNode.cpp:638 #7 0x0805d306 in VisualizerApplication::adjustNodes (this=0x9cd4808) at ../src/VisualizerApplication.cpp:236 #8 0xb6e867f0 in ?? () from /usr/lib/libSDL_mixer-1.2.so.0 #9 0xb6e8719a in ?? () from /usr/lib/libSDL_mixer-1.2.so.0 #10 0xb6ed9b0d in ?? () from /usr/lib/libSDL-1.2.so.0 #11 0xb6ee185e in ?? () from /usr/lib/libSDL-1.2.so.0 #12 0xb6f2e0bd in ?? () from /usr/lib/libSDL-1.2.so.0 #13 0xb6bc7955 in start_thread (arg=0xb198ab70) at pthread_create.c:300 #14 0xb6ca6e7e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130 (gdb) Ogre.log: (http)://pastie.org/1581790

    Read the article

  • "Expected initializer before '<' token" in header file

    - by Sarah
    I'm pretty new to programming and am generally confused by header files and includes. I would like help with an immediate compile problem and would appreciate general suggestions about cleaner, safer, slicker ways to write my code. I'm currently repackaging a lot of code that used to be in main() into a Simulation class. I'm getting a compile error with the header file for this class. I'm compiling with gcc version 4.2.1. // Simulation.h #ifndef SIMULATION_H #define SIMULATION_H #include <cstdlib> #include <iostream> #include <cmath> #include <string> #include <fstream> #include <set> #include <boost/multi_index_container.hpp> #include <boost/multi_index/hashed_index.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/mem_fun.hpp> #include <boost/multi_index/composite_key.hpp> #include <boost/shared_ptr.hpp> #include <boost/tuple/tuple_comparison.hpp> #include <boost/tuple/tuple_io.hpp> #include "Parameters.h" #include "Host.h" #include "rng.h" #include "Event.h" #include "Rdraws.h" typedef multi_index_container< // line 33 - first error boost::shared_ptr< Host >, indexed_by< hashed_unique< const_mem_fun<Host,int,&Host::getID> >, // 0 - ID index ordered_non_unique< tag<age>,const_mem_fun<Host,int,&Host::getAgeInY> >, // 1 - Age index hashed_non_unique< tag<household>,const_mem_fun<Host,int,&Host::getHousehold> >, // 2 - Household index ordered_non_unique< // 3 - Eligible by age & household tag<aeh>, composite_key< Host, const_mem_fun<Host,int,&Host::getAgeInY>, const_mem_fun<Host,bool,&Host::isEligible>, const_mem_fun<Host,int,&Host::getHousehold> > >, ordered_non_unique< // 4 - Eligible by household (all single adults) tag<eh>, composite_key< Host, const_mem_fun<Host,bool,&Host::isEligible>, const_mem_fun<Host,int,&Host::getHousehold> > >, ordered_non_unique< // 5 - Household & age tag<ah>, composite_key< Host, const_mem_fun<Host,int,&Host::getHousehold>, const_mem_fun<Host,int,&Host::getAgeInY> > > > // end indexed_by > HostContainer; typedef std::set<int> HHSet; class Simulation { public: Simulation( int sid ); ~Simulation(); // MEMBER FUNCTION PROTOTYPES void runDemSim( void ); void runEpidSim( void ); void ageHost( int id ); int calcPartnerAge( int a ); void executeEvent( Event & te ); void killHost( int id ); void pairHost( int id ); void partner2Hosts( int id1, int id2 ); void fledgeHost( int id ); void birthHost( int id ); void calcSI( void ); double beta_ij_h( int ai, int aj, int s ); double beta_ij_nh( int ai, int aj, int s ); private: // SIMULATION OBJECTS double t; double outputStrobe; int idCtr; int hholdCtr; int simID; RNG rgen; HostContainer allHosts; // shared_ptr to Hosts - line 102 - second error HHSet allHouseholds; int numInfecteds[ INIT_NUM_AGE_CATS ][ INIT_NUM_STYPES ]; EventPQ currentEvents; // STREAM MANAGEMENT void writeOutput(); void initOutput(); void closeOutput(); std::ofstream ageDistStream; std::ofstream ageDistTStream; std::ofstream hhDistStream; std::ofstream hhDistTStream; std::string ageDistFile; std::string ageDistTFile; std::string hhDistFile; std::string hhDistTFile; }; #endif I'm hoping the other files aren't so relevant to this problem. When I compile with g++ -g -o -c a.out -I /Applications/boost_1_42_0/ Host.cpp Simulation.cpp rng.cpp main.cpp Rdraws.cpp I get Simulation.h:33: error: expected initializer before '<' token Simulation.h:102: error: 'HostContainer' does not name a type and then a bunch of other errors related to not recognizing the HostContainer. It seems like I have all the right Boost #includes for the HostContainer to be understood. What else could be going wrong? I would appreciate immediate suggestions, troubleshooting tips, and other advice about my code. My plan is to create a "HostContainer.h" file that includes the typedef and structs that define its tags, similar to what I'm doing in "Event.h" for the EventPQ container. I'm assuming this is legal and good form.

    Read the article

  • Creating a voxel world with 3D arrays using threads

    - by Sean M.
    I am making a voxel game (a bit like Minecraft) in C++(11), and I've come across an issue with creating a world efficiently. In my program, I have a World class, which holds a 3D array of Region class pointers. When I initialize the world, I give it a width, height, and depth so it knows how large of a world to create. Each Region is split up into a 32x32x32 area of blocks, so as you may guess, it takes a while to initialize the world once the world gets to be above 8x4x8 Regions. In order to alleviate this issue, I thought that using threads to generate different levels of the world concurrently would make it go faster. Having not used threads much before this, and being still relatively new to C++, I'm not entirely sure how to go about implementing one thread per level (level being a xz plane with a height of 1), when there is a variable number of levels. I tried this: for(int i = 0; i < height; i++) { std::thread th(std::bind(&World::load, this, width, height, depth)); th.join(); } Where load() just loads all Regions at height "height". But that executes the threads one at a time (which makes sense, looking back), and that of course takes as long as generating all Regions in one loop. I then tried: std::thread t1(std::bind(&World::load, this, w, h1, h2 - 1, d)); std::thread t2(std::bind(&World::load, this, w, h2, h3 - 1, d)); std::thread t3(std::bind(&World::load, this, w, h3, h4 - 1, d)); std::thread t4(std::bind(&World::load, this, w, h4, h - 1, d)); t1.join(); t2.join(); t3.join(); t4.join(); This works in that the world loads about 3-3.5 times faster, but this forces the height to be a multiple of 4, and it also gives the same exact VAO object to every single Region, which need individual VAOs in order to render properly. The VAO of each Region is set in the constructor, so I'm assuming that somehow the VAO number is not thread safe or something (again, unfamiliar with threads). So basically, my question is two one-part: How to I implement a variable number of threads that all execute at the same time, and force the main thread to wait for them using join() without stopping the other threads? How do I make the VAO objects thread safe, so when a bunch of Regions are being created at the same time across multiple threads, they don't all get the exact same VAO? Turns out it has to do with GL contexts not working across multiple threads. I moved the VAO/VBO creation back to the main thread. Fixed! Here is the code for block.h/.cpp, region.h/.cpp, and CVBObject.h/.cpp which controls VBOs and VAOs, in case you need it. If you need to see anything else just ask. EDIT: Also, I'd prefer not to have answers that are like "you should have used boost". I'm trying to do this without boost to get used to threads before moving onto other libraries.

    Read the article

  • How to befriend a templated class's constructor?

    - by Kyle
    Why does class A; template<typename T> class B { private: A* a; public: B(); }; class A : public B<int> { private: friend B<int>::B<int>(); int x; }; template<typename T> B<T>::B() { a = new A; a->x = 5; } int main() { return 0; } result in ../src/main.cpp:15: error: invalid use of constructor as a template ../src/main.cpp:15: note: use ‘B::B’ instead of ‘B::class B’ to name the constructor in a qualified name yet changing friend B<int>::B<int>() to friend B<int>::B() results in ../src/main.cpp:15: error: no ‘void B::B()’ member function declared in class ‘B’ while removing the template completely class A; class B { private: A* a; public: B(); }; class A : public B { private: friend B::B(); int x; }; B::B() { a = new A; a->x = 5; } int main() { return 0; } compiles and executes just fine -- despite my IDE saying friend B::B() is invalid syntax?

    Read the article

  • BN_hex2bn magicaly segfaults in openSSL

    - by xunil154
    Greetings, this is my first post on stackoverflow, and i'm sorry if its a bit long. I'm trying to build a handshake protocol for my own project and am having issues with the server converting the clients RSA's public key to a Bignum. It works in my clent code, but the server segfaults when attempting to convert the hex value of the clients public RSA to a bignum. I have already checked that there is no garbidge before or after the RSA data, and have looked online, but i'm stuck. header segment: typedef struct KEYS { RSA *serv; char* serv_pub; int pub_size; RSA *clnt; } KEYS; KEYS keys; Initializing function: // Generates and validates the servers key /* code for generating server RSA left out, it's working */ //Set client exponent keys.clnt = 0; keys.clnt = RSA_new(); BN_dec2bn(&keys.clnt->e, RSA_E_S); // RSA_E_S contains the public exponent Problem code (in Network::server_handshake): // *Recieved an encrypted message from the network and decrypt into 'buffer' (1024 byte long)* cout << "Assigning clients RSA" << endl; // I have verified that 'buffer' contains the proper key if (BN_hex2bn(&keys.clnt->n, buffer) < 0) { Error("ERROR reading server RSA"); } cout << "clients RSA has been assigned" << endl; The program segfaults at BN_hex2bn(&keys.clnt->n, buffer) with the error (valgrind output) Invalid read of size 8 at 0x50DBF9F: BN_hex2bn (in /usr/lib/libcrypto.so.0.9.8) by 0x40F23E: Network::server_handshake() (Network.cpp:177) by 0x40EF42: Network::startNet() (Network.cpp:126) by 0x403C38: main (server.cpp:51) Address 0x20 is not stack'd, malloc'd or (recently) free'd Process terminating with default action of signal 11 (SIGSEGV) Access not within mapped region at address 0x20 at 0x50DBF9F: BN_hex2bn (in /usr/lib/libcrypto.so.0.9.8) And I don't know why it is, Im using the exact same code in the client program, and it works just fine. Any input is greatly appriciated!

    Read the article

  • C++: Explicit DLL Loading: First-chance Exception on non "extern C" functions

    - by Shiftbit
    I am having trouble importing my C++ functions. If I declare them as C functions I can successfully import them. When explicit loading, if any of the functions are missing the extern as C decoration I get a the following exception: First-chance exception at 0x00000000 in cpp.exe: 0xC0000005: Access violation. DLL.h: extern "C" __declspec(dllimport) int addC(int a, int b); __declspec(dllimport) int addCpp(int a, int b); DLL.cpp: #include "DLL.h" int addC(int a, int b) { return a + b; } int addCpp(int a, int b) { return a + b; } main.cpp: #include "..DLL/DLL.h" #include <stdio.h> #include <windows.h> int main() { int a = 2; int b = 1; typedef int (*PFNaddC)(int,int); typedef int (*PFNaddCpp)(int,int); HMODULE hDLL = LoadLibrary(TEXT("../Debug/DLL.dll")); if (hDLL != NULL) { PFNaddC pfnAddC = (PFNaddC)GetProcAddress(hDLL, "addC"); PFNaddCpp pfnAddCpp = (PFNaddCpp)GetProcAddress(hDLL, "addCpp"); printf("a=%d, b=%d\n", a,b); printf("pfnAddC: %d\n", pfnAddC(a,b)); printf("pfnAddCpp: %d\n", pfnAddCpp(a,b)); //EXCEPTION ON THIS LINE } getchar(); return 0; } How can I import c++ functions for dynamic loading? I have found that the following code works with implicit loading by referencing the *.lib, but I would like to learn about dynamic loading. Thank you to all in advance.

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >