Search Results

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

Page 16/66 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Bash alias to open Vim at last edit mark

    - by Pierre LaFayette
    The mark " in Vim takes you to your last edit position. I want to create an alias that will open my Vim instance and jump to that mark; something which is obviously extremely useful. This works from the command line: $ vim -c "'\"" File.cpp Now I want to make an alias for this: $ alias v='vim -c "'\"" File.cpp' Well that's not going to work! You need to escape the first single quote you say... $ alias v='vim -c "\'\"" File.cpp' Hmm. That didn't work either... So I try a whole lot of variations of single quoted and double quoted madness, bang my head against the table and load up stackoverflow in my browser, and here we are. How do I properly escape this alias?

    Read the article

  • Calling cli::array<int>::Reverse via a typedef in C++/CLI

    - by Vulcan Eager
    Here is what I'm trying: typedef cli::array<int> intarray; int main(){ intarray ^ints = gcnew intarray { 0, 1, 2, 3 }; intarray::Reverse(ints); // C2825, C2039, C3149 return 0; } Compilation resulted in the following errors: .\ints.cpp(46) : error C2825: 'intarray': must be a class or namespace when followed by '::' .\ints.cpp(46) : error C2039: 'Reverse' : is not a member of '`global namespace'' .\ints.cpp(46) : error C3149: 'cli::array<Type>' : cannot use this type here without a top-level '^' with [ Type=int ] Am I doing something wrong here?

    Read the article

  • Linking C and CXX files in CMake

    - by vedro so snegom
    Hi I'm building C++ app with CMake. But it uses some source files in C. Here is simplified structure: trunk/CMakeLists.txt: project(myapp) set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -g -Wall") add_subdirectory (src myapp) trunk/src/main.cpp: #include "smth/f.h" int main() { f(); } trunk/src/CMakeLists.txt: add_subdirectory (smth) link_directories (smth) set(APP_SRC main) add_executable (myapp ${APP_SRC}) target_link_libraries (myapp smth) trunk/src/smth/f.h: #ifndef F_H #define F_H void f(); #endif trunk/src/smth/f.c: #include "f.h" void f() {} trunk/src/smth/CMakeLists.txt set (SMTH_SRC some_cpp_file1 some_cpp_file2 f) add_library (smth STATIC ${SMTH_SRC}) The problem is: i run gmake, it compiles all the files and when it links all libs together, i get: undefined reference to `f()` in main.cpp if i rename f.c into f.cpp everything goes just fine. What's the difference and how to handle it? Thanks

    Read the article

  • Convert "this" to a reference-to-pointer

    - by Austin Hyde
    Just stumbled onto this problem. (title says it all) Let's say I have a struct struct Foo { void bar () { do_baz(this); } void do_baz(Foo*& pFoo) { pFoo->p_sub_foo = new Foo; // for example } Foo* p_sub_foo; } GCC tells me that temp.cpp: In member function ‘void Foo::bar()’: temp.cpp:3: error: no matching function for call to ‘Foo::do_baz(Foo* const)’ temp.cpp:5: note: candidates are: void Foo::do_baz(Foo*&) So, how do I convert what is apparently a const Foo* to a Foo*&?

    Read the article

  • C++ Mutexes and STL Lists Across Subclasses

    - by Genesis
    I am currently writing a multi-threaded C++ server using Poco and am now at the point where I need to be keeping information on which users are connected, how many connections each of them have, and given it is a proxy server, where each of those connections are proxying through to. For this purpose I have created a ServerStats class which holds an STL list of ServerUser objects. The ServerStats class includes functions which can add and remove objects from the list as well as find a user in the list an return a pointer to them so I can access member functions within any given ServerUser object in the list. The ServerUser class contains an STL list of ServerConnection objects and much like the ServerStats class it contains functions to add, remove and find elements within this list. Now all of the above is working but I am now trying to make it threadsafe. I have defined a Poco::FastMutex within the ServerStats class and can lock/unlock this in the appropriate places so that STL containers are not modified at the same time as being searched for example. I am however having an issue setting up mutexes within the ServerUser class and am getting the following compiler error: /root/poco/Foundation/include/Poco/Mutex.h: In copy constructor âServerUser::ServerUser(const ServerUser&)â: src/SocksServer.cpp:185: instantiated from âvoid __gnu_cxx::new_allocator<_Tp::construct(_Tp*, const _Tp&) [with _Tp = ServerUser]â /usr/include/c++/4.4/bits/stl_list.h:464: instantiated from âstd::_List_node<_Tp* std::list<_Tp, _Alloc::_M_create_node(const _Tp&) [with _Tp = ServerUser, _Alloc = std::allocator]â /usr/include/c++/4.4/bits/stl_list.h:1407: instantiated from âvoid std::list<_Tp, _Alloc::_M_insert(std::_List_iterator<_Tp, const _Tp&) [with _Tp = ServerUser, _Alloc = std::allocator]â /usr/include/c++/4.4/bits/stl_list.h:920: instantiated from âvoid std::list<_Tp, _Alloc::push_back(const _Tp&) [with _Tp = ServerUser, _Alloc = std::allocator]â src/SocksServer.cpp:301: instantiated from here /root/poco/Foundation/include/Poco/Mutex.h:164: error: âPoco::FastMutex::FastMutex(const Poco::FastMutex&)â is private src/SocksServer.cpp:185: error: within this context In file included from /usr/include/c++/4.4/x86_64-linux-gnu/bits/c++allocator.h:34, from /usr/include/c++/4.4/bits/allocator.h:48, from /usr/include/c++/4.4/string:43, from /root/poco/Foundation/include/Poco/Bugcheck.h:44, from /root/poco/Foundation/include/Poco/Foundation.h:147, from /root/poco/Net/include/Poco/Net/Net.h:45, from /root/poco/Net/include/Poco/Net/TCPServerParams.h:43, from src/SocksServer.cpp:1: /usr/include/c++/4.4/ext/new_allocator.h: In member function âvoid __gnu_cxx::new_allocator<_Tp::construct(_Tp*, const _Tp&) [with _Tp = ServerUser]â: /usr/include/c++/4.4/ext/new_allocator.h:105: note: synthesized method âServerUser::ServerUser(const ServerUser&)â first required here src/SocksServer.cpp: At global scope: src/SocksServer.cpp:118: warning: âstd::string getWord(std::string)â defined but not used make: * [/root/poco/SocksServer/obj/Linux/x86_64/debug_shared/SocksServer.o] Error 1 The code for the ServerStats, ServerUser and ServerConnection classes is below: class ServerConnection { public: bool continue_connection; int bytes_in; int bytes_out; string source_address; string destination_address; ServerConnection() { continue_connection = true; } ~ServerConnection() { } }; class ServerUser { public: string username; int connection_count; string client_ip; ServerUser() { } ~ServerUser() { } ServerConnection* addConnection(string source_address, string destination_address) { //FastMutex::ScopedLock lock(_connection_mutex); ServerConnection connection; connection.source_address = source_address; connection.destination_address = destination_address; client_ip = getWord(source_address, ":"); _connections.push_back(connection); connection_count++; return &_connections.back(); } void removeConnection(string source_address) { //FastMutex::ScopedLock lock(_connection_mutex); for(list<ServerConnection>::iterator it = _connections.begin(); it != _connections.end(); it++) { if(it->source_address == source_address) { it = _connections.erase(it); connection_count--; } } } void disconnect() { //FastMutex::ScopedLock lock(_connection_mutex); for(list<ServerConnection>::iterator it = _connections.begin(); it != _connections.end(); it++) { it->continue_connection = false; } } list<ServerConnection>* getConnections() { return &_connections; } private: list<ServerConnection> _connections; //UNCOMMENTING THIS LINE BREAKS IT: //mutable FastMutex _connection_mutex; }; class ServerStats { public: int current_users; ServerStats() { current_users = 0; } ~ServerStats() { } ServerUser* addUser(string username) { FastMutex::ScopedLock lock(_user_mutex); for(list<ServerUser>::iterator it = _users.begin(); it != _users.end(); it++) { if(it->username == username) { return &(*it); } } ServerUser newUser; newUser.username = username; _users.push_back(newUser); current_users++; return &_users.back(); } void removeUser(string username) { FastMutex::ScopedLock lock(_user_mutex); for(list<ServerUser>::iterator it = _users.begin(); it != _users.end(); it++) { if(it->username == username) { _users.erase(it); current_users--; break; } } } ServerUser* getUser(string username) { FastMutex::ScopedLock lock(_user_mutex); for(list<ServerUser>::iterator it = _users.begin(); it != _users.end(); it++) { if(it->username == username) { return &(*it); } } return NULL; } private: list<ServerUser> _users; mutable FastMutex _user_mutex; }; Now I have never used C++ for a project of this size or mutexes for that matter so go easy please :) Firstly, can anyone tell me why the above is causing a compiler error? Secondly, can anyone suggest a better way of storing the information I require? Bear in mind that I need to update this info whenever connections come or go and it needs to be global to the whole server.

    Read the article

  • How to make automake less ugly?

    - by Brendan Long
    I recently learned how to use automake, and I'm somewhat annoyed that my compile commands went from a bunch of: g++ -O2 -Wall -c fileName.cpp To a bunch of: depbase=`echo src/Unit.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ g++ -DHAVE_CONFIG_H -I. -I./src -g -O2 -MT src/Unit.o -MD -MP -MF $depbase.Tpo -c -o src/Unit.o src/Unit.cpp &&\ mv -f $depbase.Tpo $depbase.Po Is there any way to clean this up? I can usually easily pick out warning messages, but now the wall of text to read though is 3x bigger and much weirder. I know what my flags are, so making it just says "Compiling xxx.cpp" for each file would be perfect.

    Read the article

  • Compiling a c++ project using blas (Fortran) in Matlab mex

    - by Yin Zhu
    I am trying to use a package here. I have no problem compiling it under 64-bit Linux as all the Makefiles are already provides. Only minor changes are needed, which I can handle. However, I have a problem compiling it under 64-bit Windows. I have installed gfortran and also compiled BLAS and CBLAS to their static libraries. The problem is that Matlab mex does not support GCC in windows, so I need to use VC 2008 instead. I found in the Makefile this line is to get the final klr_train.mexw64: klr_train.$(MEX_EXT): klr_train.cpp $(MEX) $(MEX_OPTION) klr_train.cpp ../libklr/libklr.cpp $(CBLASDIR)/lib/LINUX/cblas_LINUX.a $(BLASDIR)/blas_LINUX.a -lgfortran I don't know how to execute this line using VC 2008's command line tool cl. As cl obviously does not support -lgfortran, which I think is used to link some library in gfortran to support BLAS.

    Read the article

  • C++ porting templates to Red hat enterprise linux version 5

    - by mkal
    #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> template <class OutType> bool getVAL(OutType &value_out, const std::string &key) { return false; } int main (int argc, char*argv[]) { mode_t a; getVAL(a, "abc"); } test.cpp:6: error: ISO C++ forbids declaration of ‘parameter’ with no type test.cpp: In function ‘int main(int, char**)’: test.cpp:13: error: no matching function for call to ‘getVAL(mode_t&, const char [4])’

    Read the article

  • Using Library files in Linux

    - by paultop6
    Hi Guys, Im trying to use some of the functions that are in the /lib/libproc-3.2.6.so library in my Ubuntu Distribution. I have downloaded and installed the header files and they are defined in my source files. Currently this is all im trying to do, just for starters... proc_t **read_proc = readproctab(0); But i get the following compiler error: /tmp/cclqMImG.o: In function `Sysmon::initialise_sysmon()': sysmon.cpp:(.text+0x494): undefined reference to `readproctab' collect2: ld returned 1 exit status Im aware im probably doing some wrong with the command im using to compile it, but due to lack of experience im not sure what im doign wrong. This is the g++ command im using to compile my cpp file: g++ -o sysmon.o sysmon.cpp `pkg-config --libs --cflags gtk+-2.0` Can someone please give me some pointers as to where im going wrong Regards Paul

    Read the article

  • C++: Declaration of template class member specialization (+ Doxygen bonus question!)

    - by Ziv
    When I specialize a (static) member function/constant in a template class, I'm confused as to where the declaration is meant to go. Here's an example of what I what to do - yoinked directly from IBM's reference on template specialization: template<class T> class X { public: static T v; static void f(T); }; template<class T> T X<T>::v = 0; template<class T> void X<T>::f(T arg) { v = arg; } template<> char* X<char*>::v = "Hello"; template<> void X<float>::f(float arg) { v = arg * 2; } int main() { X<char*> a, b; X<float> c; c.f(10); // X<float>::v now set to 20 } The question is, how do I divide this into header/cpp files? The generic implementation is obviously in the header, but what about the specialization? It can't go in the header file, because it's concrete, leading to multiple definition. But if it goes into the .cpp file, is code which calls X::f() aware of the specialization, or might it rely on the generic X::f()? So far I've got the specialization in the .cpp only, with no declaration in the header. I'm not having trouble compiling or even running my code (on gcc, don't remember the version at the moment), and it behaves as expected - recognizing the specialization. But A) I'm not sure this is correct, and I'd like to know what is, and B) my Doxygen documentation comes out wonky and very misleading (more on that in a moment). What seems most natural to me would be something like this, declaring the specialization in the header and defining it in the .cpp: ===XClass.hpp=== #ifndef XCLASS_HPP #define XCLASS_HPP template<class T> class X { public: static T v; static void f(T); }; template<class T> T X<T>::v = 0; template<class T> void X<T>::f(T arg) { v = arg; } /* declaration of specialized functions */ template<> char* X<char*>::v; template<> void X<float>::f(float arg); #endif ===XClass.cpp=== #include <XClass.hpp> /* concrete implementation of specialized functions */ template<> char* X<char*>::v = "Hello"; template<> void X<float>::f(float arg) { v = arg * 2; } ...but I have no idea if this is correct. The most immediate consequence of this issue, as I mentioned, is my Doxygen documentation, which doesn't seem to warm to the idea of member specialization, at least the way I'm defining it at the moment. It will always present only the first definition it finds of a function/constant, and I really need to be able to present the specializations as well. If I go so far as to re-declare the entire class, i.e. in the header: /* template declaration */ template<class T> class X { public: static T v; static void f(T); }; /* template member definition */ template<class T> T X<T>::v = 0; template<class T> void X<T>::f(T arg) { v = arg; } /* declaration of specialized CLASS (with definitions in .cpp) */ template<> class X<float> { public: static float v; static void f(float); }; then it will display the different variations of X as different classes (which is fine by me), but I don't know how to get the same effect when specializing only a few select members of the class. I don't know if this is a mistake of mine, or a limitation of Doxygen - any ideas? Thanks much, Ziv

    Read the article

  • Use a "User Macro" in .vcproj RelativePath

    - by Tom Leys
    Inside .vcproj files There is a list of all source files in your project. How can we use a macro to specify the path to a source file? If we do this: <File RelativePath="$(Lib3rdParty)\Qt\qtwinmigrate-2.5-commercial\src\qmfcapp.cpp"> </File> The compiler cannot find the folder: qmfcapp.cpp c1xx : fatal error C1083: Cannot open source file: '.\$(lib3rdparty)\qt\qtwinmigrate- 2.5-commercial\src\qmfcapp.cpp': No such file or directory As you can see, our project compiles in several source files from QT. QT lives inside a folder of external libraries, and we don't want hardcode the path from our project to that folder (we have a very large solution)

    Read the article

  • Where to put constant strings in C++: static class members or anonymous namespaces

    - by stone
    I need to define some constant strings that will be used only by one class. It looks like I have three options: Embed the strings directly into locations where they are used. Define them as private static constant members of the class: //A.h class A { private: static const std::string f1; static const std::string f2; static const std::string f3; }; //A.cpp const std::string f1 = "filename1"; const std::string f2 = "filename2"; const std::string f3 = "filename3"; //strings are used in this file Define them in an anonymous namespace in the cpp file: //A.cpp namespace { const std::string f1 = "filename1"; const std::string f2 = "filename2"; const std::string f3 = "filename3"; } //strings are used in this file Given these options, which one would you recommend and why? Thanks.

    Read the article

  • link .a and .o files in GCC

    - by David
    hi! I have two precompiled library: X.a and Y.a and a test.cpp (without main function) source code use these two libraries. I compiled the C++ using: g++ -c test.cpp and I got 'test.o'. Now how can I link these three together to generate a .a file because test.cpp use some function in X.a and Y.a and other GCC libraries? BTW, I am doing these under Windows using MinGW. Can I rename this .a file to .lib and use this .lib in VC? Thanks!

    Read the article

  • Undefined reference to ...

    - by Patrick LaChance
    I keep getting this error message every time I try to compile, and I cannot find out what the problem is. any help would be greatly appreciated: C:\DOCUME~1\Patrick\LOCALS~1\Temp/ccL92mj9.o:main.cpp:(.txt+0x184): undefined reference to 'List::List()' C:\DOCUME~1\Patrick\LOCALS~1\Temp/ccL92mj9.o:main.cpp:(.txt+0x184): undefined reference to 'List::add(int)' collect2: ld returned 1 exit status code: //List.h #ifndef LIST_H #define LIST_H #include <exception> //brief Definition of linked list class class List { public: /** \brief Exception for operating on empty list */ class Empty : public std::exception { public: virtual const char* what() const throw(); }; /** \brief Exception for invalid operations other than operating on an empty list */ class InvalidOperation : public std::exception { public: virtual const char* what() const throw(); }; /** \brief Node within List */ class Node { public: /** data element stored in this node */ int element; /** next node in list */ Node* next; /** previous node in list */ Node* previous; Node (int element); ~Node(); void print() const; void printDebug() const; }; List(); ~List(); void add(int element); void remove(int element); int first()const; int last()const; int removeFirst(); int removeLast(); bool isEmpty()const; int size()const; void printForward() const; void printReverse() const; void printDebug() const; /** enables extra output for debugging purposes */ static bool traceOn; private: /** head of list */ Node* head; /** tail of list */ Node* tail; /** count of number of nodes */ int count; }; #endif //List.cpp I only included the parts of List.cpp that might be the issue #include "List.h" #include <iostream> #include <iomanip> using namespace std; List::List() { //List::size = NULL; head = NULL; tail = NULL; } List::~List() { Node* current; while(head != NULL) { current = head-> next; delete current->previous; if (current->next!=NULL) { head = current; } else { delete current; } } } void List::add(int element) { Node* newNode; Node* current; newNode->element = element; if(newNode->element > head->element) { current = head->next; } else { head->previous = newNode; newNode->next = head; newNode->previous = NULL; return; } while(newNode->element > current->element) { current = current->next; } if(newNode->element <= current->element) { newNode->previous = current->previous; newNode->next = current; } } //main.cpp #include "List.h" #include <iostream> #include <string> using namespace std; //void add(int element); int main (char** argv, int argc) { List* MyList = new List(); bool quit = false; string value; int element; while(quit==false) { cin>>value; if(value == "add") { cin>>element; MyList->add(element); } if(value=="quit") { quit = true; } } return 0; } I'm doing everything I think I'm suppose to be doing. main.cpp isn't complete yet, just trying to get the add function to work first. Any help will be greatly appreciated.

    Read the article

  • C++ 'ClassName Not Declared' Error

    - by Arjun Nayini
    I have this cpp file. dsets.cpp: #ifndef DSETS_CPP #define DSET_CPP //Adds elements to the DisjointSet data structure. This function adds //x unconnected roots to the end of the array. void DisjointSets::addelements(int x){ } //Given an int this function finds the root associated with that node. int DisjointSets::find(int x){ return 0; } //This function reorders the uptree in order to represent the union of two //subtrees void DisjointSets::setunion(int x, int y){ } #endif and this header file dsets.h: #ifndef DSETS_H #define DSET_H #include <iostream> #include <vector> using namespace std; class DisjointSets { public: void addelements(int x); int find(int x); void setunion(int x, int y); private: vector<int> x; }; #include "dsets.cpp" #endif And I keep getting an error that is saying that "DisjointSets has no been declared" ~ ~

    Read the article

  • Declaring STL Data Structures such as Vector in the .h

    - by sc_ray
    I am trying to declare a private Data Structure such as the Vector in my C++ header file which I want to eventually use within the method implementation of my .cpp. An example would be my header "SomeClass.h" where I have: class SomeClass { private: Vector<T> myVector; public: void AddTtoMyVector(T add); } And in my .cpp which is "SomeClass.cpp", I have the following: #include "SomeClass.h" SomeClass::AddTtoMyVector(T add) { myVector.Push_back(add); } Would the syntax here work? Or is there a different way of declaring and populating such structures?

    Read the article

  • (C++) Linking with namespaces causes duplicate symbol error

    - by user577072
    Hello. For the past few days, I have been trying to figure out how to link the files for a CLI gaming project I have been working on. There are two halves of the project, the Client and the Server code. The client needs two libraries I've made. The first is a general purpose game board. This is split between GameEngine.h and GameEngine.cpp. The header file looks something like this namespace gfdGaming { // struct sqr_size { // Index x; // Index y; // }; typedef struct { Index x, y; } sqr_size; const sqr_size sPos = {1, 1}; sqr_size sqr(Index x, Index y); sqr_size ePos; class board { // Prototypes / declarations for the class } } And the CPP file is just giving everything content #include "GameEngine.h" type gfdGaming::board::functions The client also has game-specific code (in this case, TicTacToe) split into declarations and definitions (TTT.h, Client.cpp). TTT.h is basically #include "GameEngine.h" #define TTTtar "localhost" #define TTTport 2886 using namespace gfdGaming; void* turnHandler(void*); namespace nsTicTacToe { GFDCON gfd; const char X = 'X'; const char O = 'O'; string MPhostname, mySID; board TTTboard; bool PlayerIsX = true, isMyTurn; char Player = X, Player2 = O; int recon(string* datHolder = NULL, bool force = false); void initMP(bool create = false, string hn = TTTtar); void init(); bool isTie(); int turnPlayer(Index loc, char lSym = Player); bool checkWin(char sym = Player); int mainloop(); int mainloopMP(); }; // NS I made the decision to put this in a namespace to group it instead of a class because there are some parts that would not work well in OOP, and it's much easier to implement later on. I have had trouble linking the client in the past, but this setup seems to work. My server is also split into two files, Server.h and Server.cpp. Server.h contains exactly: #include "../TicTacToe/TTT.h" // Server needs a full copy of TicTacToe code class TTTserv; struct TTTachievement_requirement { Index id; Index loc; bool inUse; }; struct TTTachievement_t { Index id; bool achieved; bool AND, inSameGame; bool inUse; bool (*lHandler)(TTTserv*); char mustBeSym; int mustBePlayer; string name, description; TTTachievement_requirement steps[safearray(8*8)]; }; class achievement_core_t : public GfdOogleTech { public: // May be shifted to private TTTachievement_t list[safearray(8*8)]; public: achievement_core_t(); int insert(string name, string d, bool samegame, bool lAnd, int lSteps[8*8], int mbP=0, char mbS=0); }; struct TTTplayer_t { Index id; bool inUse; string ip, sessionID; char sym; int desc; TTTachievement_t Ding[8*8]; }; struct TTTgame_t { TTTplayer_t Player[safearray(2)]; TTTplayer_t Spectator; achievement_core_t achievement_core; Index cTurn, players; port_t roomLoc; bool inGame, Xused, Oused, newEvent; }; class TTTserv : public gSserver { TTTgame_t Game; TTTplayer_t *cPlayer; port_t conPort; public: achievement_core_t *achiev; thread threads[8]; int parseit(string tDat, string tsIP); Index conCount; int parseit(string tDat, int tlUser, TTTplayer_t** retval); private: int parseProto(string dat, string sIP); int parseProto(string dat, int lUser); int cycleTurn(); void setup(port_t lPort = 0, bool complete = false); public: int newEvent; TTTserv(port_t tlPort = TTTport, bool tcomplete = true); TTTplayer_t* userDC(Index id, Index force = false); int sendToPlayers(string dat, bool asMSG = false); int mainLoop(volatile bool *play); }; // Other void* userHandler(void*); void* handleUser(void*); And in the CPP file I include Server.h and provide main() and the contents of all functions previously declared. Now to the problem at hand I am having issues when linking my server. More specifically, I get a duplicate symbol error for every variable in nsTicTacToe (and possibly in gfdGaming as well). Since I need the TicTacToe functions, I link Client.cpp ( without main() ) when building the server ld: duplicate symbol nsTicTacToe::PlayerIsX in Client.o and Server.o collect2: ld returned 1 exit status Command /Developer/usr/bin/g++-4.2 failed with exit code 1 It stops once a problem is encountered, but if PlayerIsX is removed / changed temporarily than another variable causes an error Essentially, I am looking for any advice on how to better organize my code to hopefully fix these errors. Disclaimers: -I apologize in advance if I provided too much or too little information, as it is my first time posting -I have tried using static and extern to fix these problems, but apparently those are not what I need Thank you to anyone who takes the time to read all of this and respond =)

    Read the article

  • Vim open file under cursor

    - by ereOn
    Hi, Let's say I have the following file tree: / include/ library/ a.hpp b.hpp src/ a.cpp b.cpp And the following /src/a.cpp file: #include "a.hpp" #include "b.hpp" I always open Vim at the root directory. So when I want to load a.hpp I do : :tabnew include/library/a.hpp or: :tabnew **/a.hpp I'd like to map <F4> to open the file under the cursor in a new tab, using a recursive search. I tried the following mapping command: :map <F4> :tabnew **/expand("<cfile>")<cr> But obviously, this can't work, as it tries to open the file "/expand(" instead. Any clue on how I could do that ? Thanks.

    Read the article

  • c++ undefined references with static library

    - by stupid_idiot
    hi guys i'm trying to make a static library from a class but when trying to use it i always get errors with undefined references on anything. the way i proceeded was creating the object file like g++ -c myClass.cpp -o myClass.o and then packing it with ar rcs myClass.lib myClass.o there is something i'm obviously missing generaly with this.. i bet it's something with symbols.. thx for any advices, i know it's most probably something i could find out if reading some tutorial so sorry if bothering with stupid stuff again :) edit: myClass.h: class myClass{ public: myClass(); void function(); }; myClass.cpp: #include "myClass.h" myClass::myClass(){} void myClass::function(){} program using the class: #include "myClass.h" int main(){ myClass mc; mc.function(); return 0; } finally i compile it like this: g++ -o main.exe -L. -l myClass main.cpp

    Read the article

  • Can't inherit from auto_ptr without problems

    - by fret
    What I want to do is this: #include <memory> class autostr : public std::auto_ptr<char> { public: autostr(char *a) : std::auto_ptr<char>(a) {} autostr(autostr &a) : std::auto_ptr<char>(a) {} // define a bunch of string utils here... }; autostr test(char a) { return autostr(new char(a)); } void main(int args, char **arg) { autostr asd = test('b'); return 0; } (I actually have a copy of the auto_ptr class that handles arrays as well, but the same error applies to the stl one) The compile error using GCC 4.3.0 is: main.cpp:152: error: no matching function for call to `autostr::autostr(autostr)' main.cpp:147: note: candidates are: autostr::autostr(autostr&) main.cpp:146: note: autostr::autostr(char*) I don't understand why it's not matching the autostr argument as a valid parameter to autostr(autostr&).

    Read the article

  • Can't inherit from auto_str without problems

    - by fret
    What I want to do is this: #include <memory> class autostr : public std::auto_ptr<char> { public: autostr(char *a) : std::auto_ptr<char>(a) {} autostr(autostr &a) : std::auto_ptr<char>(a) {} // define a bunch of string utils here... }; autostr test(char a) { return autostr(new char(a)); } void main(int args, char **arg) { autostr asd = test('b'); return 0; } (I actually have a copy of the auto_ptr class that handles arrays as well, but the same error applies to the stl one) The compile error using GCC 4.3.0 is: main.cpp:152: error: no matching function for call to `autostr::autostr(autostr)' main.cpp:147: note: candidates are: autostr::autostr(autostr&) main.cpp:146: note: autostr::autostr(char*) I don't understand why it's not matching the autostr argument as a valid parameter to autostr(autostr&).

    Read the article

  • wxWidgets and Dev-C++

    - by Anteater7171
    I've been using Bloodshed Dev-C++ for C++ programing for a while now. I'd like to get into GUI programing in C++. So I installed wxWidget and tried a simple hello world program, yet I get the following error: \Dev-Cpp\gui_at0.cpp C:\Dev-Cpp\C wx/wx.h: No such file or directory. I'm pretty sure this error is due to the wx folder not being in the right directory. Currently it's in C:. So where does it need to be moved to? Or is something else at play?

    Read the article

  • How to handle splitting a file under source control?

    - by sharptooth
    I have a .cpp file and .h file containing a class. Class.cpp contains the implementation and Class.h contains the definition. The class is overcomplicated so I want to separate some code and move it into a separate class. So I create NewClass.cpp and NewClass.h and move the code there. How do I handle this when the files are under SVN? I can simply "svn add" the two new files, but then they will appear as new and will have no history. I could instead "svn copy and rename" the two initial files and edit the the two old files and the two new files - then the two new files will have common history. Which approach is better from the point of version control? Should the new files share history with the old files or should they appear as new?

    Read the article

  • Interpreter in C++: Function table storage problem

    - by sub
    In my interpreter I have built-in functions available in the language like print exit input, etc. These functions can obviously be accessed from inside the language. The interpreter then looks for the corresponding function with the right name in a vector and calls it via a pointer stored with its name. So I gather all these functions in files like io.cpp, string.cpp, arithmetic.cpp. But I have to add every function to the function list in the interpreter in order for it to be found. So in these function files I have things like: void print( arg ) { cout << arg.ToString; } I'd add this print function to the interpreter function list with: interpreter.AddFunc( "print", print ); But where should I call the interpreter.AddFunc? I can't just put it there below the print function as it has to be in a function according to the C++ syntax. Where and how should all the functions be added to the list?

    Read the article

  • Lua - initializing

    - by Ockonal
    Hello, I can't init lua correctly under Arch Linux. Lua - latest version. Here is my code: #include <stdio.h> extern "C" { #include <lua.h> #include <lauxlib.h> #include <lualib.h> } int main() { lua_State *luaVM = luaL_newstate(); if (luaVM == NULL) { printf("Error initializing lua!\n"); return -1; } luaL_openlibs(luaVM); lua_close(luaVM); return 0; } /tmp/cc0iJ6lW.o: In function main': test_lua.cpp:(.text+0xa): undefined reference toluaL_newstate' test_lua.cpp:(.text+0x34): undefined reference to `luaL_openlibs' test_lua.cpp:(.text+0x40): undefined reference to `lua_close' collect2: ld returned 1 exit status What's wrong?

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >