When linking some object files together I get a bunch of errors like:  obj-ia32/ShadowRoutine.o: In function `InitializeMap(unsigned int*)': ShadowRoutine.cpp:(.text+0x0): multiple definition of `InitializeMap(unsigned int*)' obj-ia32/ShadowRoutine.o:ShadowRoutine.cpp:(.text+0x0): first defined here   with compilation and linking commands of:  g++ -DBIGARRAY_MULTIPLIER=1 -Wall -Wno-unknown-pragmas -fno-stack-protector \     -DTARGET_IA32 -DHOST_IA32 -DTARGET_LINUX  -I../../../source/include/pin \     -I../../../source/include/pin/gen -I../../../extras/components/include \     -I../../../extras/xed-ia32/include -I../../../source/tools/InstLib -O3 \     -fomit-frame-pointer -fno-strict-aliasing -Wno-unused-variable \     -Wno-unused-function -I. -Ishadow-memory -m32 -c \     -o obj-ia32/ShadowRoutine.o ShadowRoutine.cpp g++ -DBIGARRAY_MULTIPLIER=1 -Wall -Wno-unknown-pragmas -fno-stack-protector \     -DTARGET_IA32 -DHOST_IA32 -DTARGET_LINUX  -I../../../source/include/pin \     -I../../../source/include/pin/gen -I../../../extras/components/include \     -I../../../extras/xed-ia32/include -I../../../source/tools/InstLib -O3 \     -fomit-frame-pointer -fno-strict-aliasing -Wno-unused-variable \     -Wno-unused-function -I. -Ishadow-memory -m32 -c \     -o obj-ia32/Jikes.o Jikes.cpp g++ -shared -Wl,--hash-style=sysv -Wl,-Bsymbolic \     -Wl,--version-script=../../../source/include/pin/pintool.ver \     -m32 -o obj-ia32/Jikes.so obj-ia32/ClientReq.o obj-ia32/Server.o \     obj-ia32/ShadowRoutine.o obj-ia32/FncnMap.o obj-ia32/Trace.o \     obj-ia32/Jikes.o obj-ia32/ClientReq.o obj-ia32/Server.o \     obj-ia32/ShadowRoutine.o obj-ia32/FncnMap.o obj-ia32/Trace.o \     -L../../../ia32/lib -L../../../ia32/lib-ext -L../../../ia32/runtime/glibc \     -L../../../extras/xed-ia32/lib \     -L/home/karl/r/git/pin/source/tools/Jikes/zmq/inst/lib \     -lpin -lxed -lpindwarf -ldl -lzmq   The only two object files with InitializeMap are Jikes.o and ShadowRoutine.o:  $ nm obj-ia32/Jikes.o  | grep InitializeMap          U _Z13InitializeMapPj $ nm obj-ia32/ShadowRoutine.o | grep InitializeMap 00000000 T _Z13InitializeMapPj $ nm obj-ia32/* | grep InitializeMap          U _Z13InitializeMapPj 00000000 T _Z13InitializeMapPj   So why am I getting "multiple definitions of InitializeMap" if it's only "defined" in one object file and "undefined" in the only other object file that required it using extern?  This is what the declarations, definitions, and uses look like:  $ grep -r InitializeMap * Jikes.cpp:  if (rtn_name == "sysInitializeMap") {       RTN_INSERT_1(InitializeMap); Binary file obj-ia32/Jikes.o matches Binary file obj-ia32/ShadowRoutine.o matches ShadowRoutine.cpp:VOID InitializeMap(ADDRINT *smID) { init_map(*(int*)smID); } ShadowRoutine.hpp:VOID InitializeMap(ADDRINT *smID);   where both the cpp files #include "ShadowRoutine.hpp".  EDIT: My question is why does the linker command (the third g++ command in the second code snippet above) not work even though nm says that the function is only defined in the text of ShadowRoutine.o and undefined in Jikes.o?
21491
Why does C++ have header files and .cpp files?
54240
I'm trying to combine a stack data structure with a \newcounter{} definition so that I can automatically pair together a collection of points scattered throughout my text.   Each point is either marked as an \openbracket or a \closebracket, and automatically paired to an oppositely defined point in order to form \openbracket-\closebracket pairs. Closed pairs may be nested within other closed bracket pairs, and each pair of open/closed points are marked with the tikz nodes \node(openX) {}; and \node(closeX) {}; respectively [where X is an integer defined by an external counter].   For example:  \openbraket First tier     \openbraket Second tier A         \openbraket Third tier         \closebracket      \closebracket      \openbracket Second tier B     \closebracket  \closebracket    should automatically pair the above \openbracket \closebracket points into 4 closed bracket pairs; one First tier bracket, containing two Second tier brackets, the first (A) of which contains a single Third tier bracket. My MWE should also pop data from the stack structure so that the tikz nodes in the above example are defined as:   (open0) First tier (open1) Second tier A (open2) Third tier  (close2) (close1) (open3)  Second tier B (close3) (close0)   Using the help of , , and , I have managed to defined a working stack data structure and have figured out a method with which to correctly pass stack data to my \tikzmark macro.   However, the MWE below does not explicitly push the current value of the bracketpairingcounter onto the bracketpairingstack, and pushes the verbatim command string instead of the required integer number. Thus when each \node(closeX) {}; tikz mark is popped from the data stack, each node number is evaluated at the last value of bracketpairingcounter, instead of the different integers sequentially pushed onto the stack.   I'm hoping that the numbering problem can be fixed by somehow forcing my LaTeX code to immediately evaluate the value of \openbracketname below, but I can't for the life of me get \expandafter or \edef{} to work in this case...   MWE  \documentclass[openany]{article} \usepackage{tikz}  %Define stack data structure commands (\push, \pop, \splitstack) \newtoks\braketpairingstack \braketpairingstack={\empty}      \def\push#1#2{%         \def\tmp{{#1}}%          \expandafter\expandafter\expandafter%         #2\expandafter\expandafter\expandafter{\expandafter\tmp\the#2}%     \ignorespaces}      \def\pop#1#2{%         \expandafter\splitstack\the#1\stop{#1}{#2}%     }      \def\splitstack#1#2\stop#3#4{%          \def\tmp{#1}         \ifx\tmp\empty          \else             \def#4{#1}\global#3={#2}%         \fi     }   %Define \tikzmark command \def\tikzmark#1{%     \tikz[remember picture, overlay]\node[red](#1) {#1};% }  %Define bracket pair counting commands (\openbracket, \closebracket) \newcounter{bracketpairingcounter}      \newcommand{\openbraket}{%         \expandafter\edef\csname openbracketname\endcsname{\thebracketpairingcounter}%         \push{\openbracketname}{\braketpairingstack}%         \tikzmark{open\openbracketname}%         \stepcounter{bracketpairingcounter}%     }      \newcommand{\closebraket}{%         \pop{\braketpairingstack}{\closebracketname}%         \tikzmark{close\closebracketname}%     }  %Begin MWE document \begin{document}     \openbraket Open first bracket.\\ %Correctly marked as open0     \openbraket Open second bracket.\\ %Correctly marked as open1      Close second bracket. \closebraket\\ %Correctly marked as close1      Close first bracket. \closebraket\\ %Incorrectly marked as close1 \end{document}
78941
Here is a minimal example that showcases my problem:  \documentclass{article}  \usepackage{amsthm} \usepackage{hyperref} \usepackage{cleveref}  \newtheorem{thm}{Theorem} \newtheorem{lem}[thm]{Lemma}  \begin{document}  \begin{lem} Lemma \end{lem}  \end{document}   The warning I get is the following:  [1pdfTeX warning (ext4): destination with the same identifier (name{thm.1}) has been already used, duplicate ignored  \AtBegShi@Output ...ipout \box \AtBeginShipoutBox                                                    \fi \fi  l.16 \end{document}                    {&lt;install dir&gt;/MiKTeX/2.9/pdftex/config/pdftex.map}]   I know that it is just a warning and that, my document will still work perfectly fine with regards to cross-referencing and hyperlinking, but I would still like to know why I am getting this warning and if anything can be done to fix it without removing functionality of the included packages.   Bonus question: Whats going on behind the scenes when this warning (or any generic 'destination with the same identifier (name{XXX.YYY}) has been already used, duplicate ignored') is produced, as this is not limited to theorem environments.  From log file:  Package: amsthm 2004/08/06 v2.20 Package: hyperref 2011/04/17 v6.82g Hypertext links for LaTeX Package: cleveref.sty 2011/03/22 v0.17.9 Intelligent cross-referencing Package cleveref Info: `hyperref' support loaded on input line 2157. Package cleveref Info: `amsthm' support loaded on input line 2300.
8017
I often find myself in a situation where I am facing multiple compilation/linker errors in a C++ project due to some bad design decisions (made by someone else :) ) which lead to circular dependencies between C++ classes in different header files (can happen also in the same file). But fortunately(?) this doesn't happen often enough for me to remember the solution to this problem for the next time it happens again.  So for the purposes of easy recall in the future I am going to post a representative problem and a solution along with it. Better solutions are of-course welcome.     A.h  class B; class A {     int _val;     B *_b; public:      A(int val)         :_val(val)     {     }      void SetB(B *b)     {         _b = b;         _b-&gt;Print(); // COMPILER ERROR: C2027: use of undefined type 'B'     }      void Print()     {         cout&lt;&lt;"Type:A val="&lt;&lt;_val&lt;&lt;endl;     } };       B.h  #include "A.h" class B {     double _val;     A* _a; public:      B(double val)         :_val(val)     {     }      void SetA(A *a)     {         _a = a;         _a-&gt;Print();     }      void Print()     {         cout&lt;&lt;"Type:B val="&lt;&lt;_val&lt;&lt;endl;     } };       main.cpp  #include "B.h" #include &lt;iostream&gt;  int main(int argc, char* argv[]) {     A a(10);     B b(3.14);     a.Print();     a.SetB(&amp;b);     b.Print();     b.SetA(&amp;a);     return 0; }
1257
I'm currently refactoring/tidying up some old C code used in a C++ project, and regularly see functions such as:  int f(void)   which I would tend to write as:  int f()   Is there any reason not to replace (void) with () throughout the codebase in order to improve consistency, or is there a subtle difference between the two that I am unaware of?  More specifically, if a virtual member function in C++ is described as:  virtual int f(void)   and a derived class includes a member function:  int f()   is this a valid override?  Additionally, am I likely to encounter any linker problems based on almost identical signatures?
95713
While developing a C++ application, I had to use a 3rd party library which produced a huge amount of warnings related with a harmless #pragma directive being used.  ../File.hpp:1: warning: ignoring #pragma ident In file included from ../File2.hpp:47,                  from ../File3.hpp:57,                  from File4.h:49,   Is it possible to disable this kind of warnings, when using the GNU C++ compiler?
12470
Why do we need to use:  extern "C" { #include &lt;foo.h&gt; }   Specifically:     When should we use it? What is happening at the compiler/linker level that requires us to use it?   How in terms of compilation/linking does this solve the problems which require us to use it?
113560
I expected A::~A() to be called in this program, but it isn't:  #include &lt;iostream&gt;  struct A {   ~A() { std::cout &lt;&lt; "~A()" &lt;&lt; std::endl; } };  void f() {   A a;   throw "spam"; }  int main() { f(); }   However, if I change last line to   int main() try { f(); } catch (...) { throw; }   then A::~A() is called.  I am compiling with "Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86" from Visual Studio 2005. Command line is cl /EHa my.cpp.  Is compiler right as usual? What does standard say on this matter?
48897
I have a C++ library that provides various classes for managing data.  I have the source code for the library.  I want to extend the C++ API to support C function calls so that the library can be used with C code and C++ code at the same time.  I'm using GNU tool chain (gcc, glibc, etc), so language and architecture support are not an issue.  Are there any reasons why this is technically not possible?  Are there any gotcha's that I need to watch out for?  Are there resources, example code and/or documentation available regarding this?    Some other things that I have found out:   Use the following to wrap your C++ headers that need to be used by C code.     #ifdef __cplusplus extern "C" {   #endif   //   // Code goes here ...   //   #ifdef __cplusplus   } // extern "C"   #endif    Keep "real" C++ interfaces in separate header files that are not included by C.  Think  here.  Using #ifndef __cplusplus #error stuff helps here to detect any craziness. Careful of C++ identifiers as names in C code Enums varying in size between C and C++ compilers.  Probably not an issue if you're using GNU tool chain, but still, be careful. For structs follow the following form so that C does not get confused.  typedef struct X { ... } X  Then use pointers for passing around C++ objects, they just have to be declared in C as struct X where X is the C++ object.   All of this is courtesy of a friend who's a wizard at C++.
31381
The following code says that passing the map as const into the operator[] method discards qualifiers: #include &lt;iostream&gt; #include &lt;map&gt; #include &lt;string&gt;  using namespace std;  class MapWrapper { public:     const int &amp;get_value(const int &amp;key) const {         return _map[key];     }  private:     map&lt;int, int&gt; _map; };  int main() {     MapWrapper mw;     cout &lt;&lt; mw.get_value(42) &lt;&lt; endl;     return 0; }  Is this because of the possible allocation that occurs on the map access? Can no functions with map accesses be declared const? MapWrapper.cpp:10: error: passing const std::map&lt;int, int, std::less&lt;int&gt;, std::allocator&lt;std::pair&lt;const int, int&gt; &gt; &gt; as this argument of  _Tp&amp; std::map&lt;_Key, _Tp, _Compare, _Alloc&gt;::operator[](const _Key&amp;)  [with _Key = int, _Tp = int, _Compare = std::less&lt;int&gt;,  _Alloc = std::allocator&lt;std::pair&lt;const int, int&gt; &gt;] discards qualifiers
30635
I'm a C++ newbie, but I wasn't able to find the answer to this (most likely trivial) question online.  I am having some trouble compiling some code where two classes include each other.  To begin, should my #include statements go inside or outside of my macros?  In practice, this hasn't seemed to matter.  However, in this particular case, I am having trouble.  Putting the #include statements outside of the macros causes the compiler to recurse and gives me "#include nested too deeply" errors.  This seems to makes sense to me since neither class has been fully defined before #include has been invoked.  However, strangely, when I try to put them inside, I am unable to declare a type of one of the classes, for it is not recognized.  Here is, in essence, what I'm trying to compile:  A.h  #ifndef A_H_ #define A_H_  #include "B.h"  class A {     private:         B b;      public:         A() : b(*this) {} };  #endif /*A_H_*/   B.h  #ifndef B_H_ #define B_H_  #include "A.h"  class B {     private:             A&amp; a;      public:         B(A&amp; a) : a(a) {}  };  #endif /*B_H_*/   main.cpp  #include "A.h"  int main() {     A a; }   If it makes a difference, I am using g++ 4.3.2.  And just to be clear, in general, where should #include statements go?  I have always seen them go outside of the macros, but the scenario I described clearly seems to break this principle.  Thanks to any helpers in advance!  Please allow me to clarify my intent if I have made any silly mistakes!
13904
I'm doing some architectural cleanup that involves moving a bunch of classes into different projects and/or namespaces. Currently I'm moving the files by hand, building, and then manually adding using Foo statements as needed to resolve compilation errors. Anyone know of a smarter way of doing this? (We're a CodeRush and Refactor! shop, but I'd be interested to hear if Resharper has support for this)
123746
I have a problem compiling the following document.  First, I have a file macros.sty that consists of :  \newcommand{\test}{ \xymatrix@R=0mm{x} }   Then, I have an auxiliary file out.aux that consists of :  \test   Finally, the main file is :  \documentclass{article} \usepackage[all]{xy} \usepackage{macros} \begin{document} \input{out.aux} \end{document}   The error message is :  ./out.aux:1: Undefined control sequence. \xymatrix@R -&gt;\Addop@@                     \xymatrixrowsep@ \dimen@ii    Note that if you remove the R=0mm, the problem no longer holds.  Is that a bug ?  It is very strange because I remember to have already used a command similar to \test in an input file without any problem.  Does it come from my distribution ?  Thank you :)
96132
I am trying to install VMware with the instructions at   I get an error that tells me to look into a log file, which contains:  Extracting the vmmon source from "/usr/lib/vmware/modules/source/vmmon.tar". Successfully extracted the vmmon source. Building module with command "/usr/bin/make -j4 -C /tmp/modconfig-GoVdrH/vmmon-only auto-build HEADER_DIR=/lib/modules/4.15.0-22-generic/build/include CC=/usr/bin/gcc IS_GCC_3=no" Failed to build vmmon.  Failed to execute the build command.   To figure out what was wrong exactly, I ran vmware-modconfig --console --install-all on the command line, and it revealed these errors:  ./arch/x86/include/asm/processor-flags.h:39:0: note: this is the location of the previous definition  #define CR3_PCID_MASK 0xFFFull                        ^ /tmp/modconfig-3S1CBa/vmmon-only/linux/driver.c:256:12: error: ‘struct timer_list’ has no member named ‘data’     tscTimer.data     = 0;     unsigned int lockedPages = global_page_state(NR_PAGETABLE) +                                ^~~~~~~~~~~~~~~~~                                global_numa_state /tmp/modconfig-3S1CBa/vmmon-only/linux/driver.c: In function ‘init_module’: /tmp/modconfig-3S1CBa/vmmon-only/linux/driver.c:338:4: error: implicit declaration of function ‘init_timer’; did you mean ‘init_timers’? [-Werror=implicit-function-declaration]     init_timer(&amp;tscTimer);     ^~~~~~~~~~     init_timers /tmp/modconfig-3S1CBa/vmmon-only/linux/hostif.c: In function ‘HostIF_InitUptime’:     init_timers /tmp/modconfig-3S1CBa/vmmon-only/linux/hostif.c:1754:31: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]     uptimeState.timer.function = HostIFUptimeResyncMono;  LinuxDriverSyncReadTSCs(uint64 *delta) // OUT: TSC max - TSC min  ^~~~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors cc1: some warnings being treated as errors scripts/Makefile.build:332: recipe for target '/tmp/modconfig-3S1CBa/vmmon-only/linux/hostif.o' failed make[2]: *** [/tmp/modconfig-3S1CBa/vmmon-only/linux/hostif.o] Error 1 Makefile:110: recipe for target 'vmmon.ko' failed make: *** [vmmon.ko] Error 2   How to fix it, or make implicit-function-declaration and incompatible-pointer-types be not considered as errros? Or any easier method to install the latest VMware on 18.04?  Note: Different error from
110516
I am trying to perform two operations. First I want to increase the size of a GameObject and then delay for 0.1s before returning it back to its original size. However, when I try using StartCoroutine(), it keeps giving me the error :  An object reference is required to access not-static members   even though I made my Delay() function static. Can somebody please tell me what I'm doing wrong?  public static void MoveSelected(int choice) {     GameObject rock1 = GameObject.Find("Rock1");     GameObject paper1 = GameObject.Find("Paper1");     GameObject scissors1 = GameObject.Find("Scissors1");      Vector3 scl;      if (choice == 1)     {         scl = rock1.transform.localScale;         scl.x *= 1.1f;         scl.y *= 1.1f;         rock1.transform.localScale = scl;          StartCoroutine(Delay());          scl.x /= 1.1f;         scl.y /= 1.1f;         rock1.transform.localScale = scl;     }     else if (choice == 2)     {         scl = paper1.transform.localScale;         scl.x *= 1.1f;         scl.y *= 1.1f;         paper1.transform.localScale = scl;          StartCoroutine(Delay());          scl.x /= 1.1f;         scl.y /= 1.1f;         rock1.transform.localScale = scl;     }     else if (choice == 3)     {         scl = scissors1.transform.localScale;         scl.x *= 1.1f;         scl.y *= 1.1f;         scissors1.transform.localScale = scl;          StartCoroutine(Delay());          scl.x /= 1.1f;         scl.y /= 1.1f;         rock1.transform.localScale = scl;     }  }  static IEnumerator Delay() {     yield return new WaitForSeconds(0.1f); }
68932
I am using the RSA Algorithm for encryption/decryption, and in order to decrypt the files you have to deal with some pretty big values. More specifically, things like   P = C^d % n   = 62^65 % 133   Now that is really the only calculations that ill be doing. I have tried using Matt McCutchen's BigInteger Library, but I am getting a lot of compiler errors during linking, such as:  encryption.o(.text+0x187):encryption.cpp: undefined reference to `BigInteger::BigInteger(int)'  encryption.o(.text+0x302):encryption.cpp: undefined reference to `operator&lt;&lt;(std::ostream&amp;, BigInteger const&amp;)'  encryption.o(.text$_ZNK10BigIntegermlERKS_[BigInteger::operator*(BigInteger const&amp;) const]+0x63):encryption.cpp: undefined reference to `BigInteger::multiply(BigInteger const&amp;, BigInteger const&amp;)'   So I was wondering what would be the best way to go about handling the really big integers that come out of the RSA Algorithm.  I heard that a possibility would be to declare your variables as a double long, so...  long long decryptedCharacter;   but I'm not sure exactly how big of an integer that can store.    Well for example, I try to compile and run the following program using dev C++:  #include iostream  #include "bigint\BigIntegerLibrary.hh"  using namespace std;  int main() {     BigInteger a = 65536;     cout &lt;&lt; (a * a * a * a * a * a * a * a);     return 0; }   then I get those errors.  Derek, I thought that by including the BigIntegerLibrary.hh file, that the compiler would go through and compile all the necessary files that it will use.  How should I try and compile the program above in order to resolve the linking errors?
117326
I have created multiple ESRI addins, where the same code is used. I have created a class library, which I can reference rather than duplicating code. I have the following in my ESRI addin code which works fine  IMxDocument mxdoc = ArcMap.Application.Document as IMxDocument;   However if the same code is used in the class library, I am unable to build the dll. As the  class library does not know about ArcMap,   I have tried   ESRI.ArcGIS.ArcMap.Application arcmapApp = new ESRI.ArcGIS.ArcMap.Application(); IMxDocument mxdoc = arcmapApp.Document as IMxDocument;   However when I run the code in my addin (that references my Class Library), i get the following error    What is the correct way of referencing ArcMap in a class library?