简体   繁体   中英

Cross compiling on XCode and Linux?

I developed a fairly large application that was HW on my Mac with Xcode(5.1.1). All of the code runs perfectly and does what it suppose to do. However, when I recompile the same code on my University linux servers which has gcc 4.8.3 uncountable number of errors show up. The source code files were uploaded to the server using pscp command so there was not any form of modification involved. My question is: Is there a way to do a "compatibility mode" on Xcode so that I can try to fix any compatibility issues before uploading to University servers ?

EDIT: Some errors are:

BinarySearchTree.cpp:29:23: warning: non-static data member initializers only avau++11 [enabled by default]
     int insertCount = 0, containsCount = 0, removeCount = 0;
                       ^
BinarySearchTree.cpp:29:42: warning: non-static data member initializers only avau++11 [enabled by default]
     int insertCount = 0, containsCount = 0, removeCount = 0;
                                          ^
BinarySearchTree.cpp:29:59: warning: non-static data member initializers only avau++11 [enabled by default]
     int insertCount = 0, containsCount = 0, removeCount = 0;
                                                           ^
BinarySearchTree.cpp:30:21: warning: non-static data member initializers only avau++11 [enabled by default]
     int nodeCount = 0;
                     ^
BinarySearchTree.cpp:47:36: error: expected ',' or '...' before '&&' token
  BinarySearchTree(BinarySearchTree && rhs) : root{ rhs.root }
                                    ^
BinarySearchTree.cpp:47:42: error: invalid constructor; you probably meant 'BinarnarySearchTree<Comparable>&)'
  BinarySearchTree(BinarySearchTree && rhs) : root{ rhs.root }
                                          ^
BinarySearchTree.cpp:48:2: error: expected unqualified-id before '{' token
  {
  ^
BinarySearchTree.cpp:73:48: error: expected ',' or '...' before '&&' token
  BinarySearchTree & operator=(BinarySearchTree && rhs)
                                                ^
BinarySearchTree.cpp:153:25: error: expected ',' or '...' before '&&' token
  void insert(Comparable && x)
                         ^
BinarySearchTree.cpp:185:25: error: expected ',' or '...' before '&&' token
   BinaryNode(Comparable && theElement, BinaryNode *lt, BinaryNode *rt)
                         ^
BinarySearchTree.cpp:216:25: error: expected ',' or '...' before '&&' token
  void insert(Comparable && x, BinaryNode * & t)
                         ^
BinarySearchTree.cpp:216:7: error: 'void BinarySearchTree<Comparable>::insert(Com
  void insert(Comparable && x, BinaryNode * & t)
       ^
BinarySearchTree.cpp:153:7: error: with 'void BinarySearchTree<Comparable>::inser
  void insert(Comparable && x)
       ^
BinarySearchTree.cpp: In constructor 'BinarySearchTree<Comparable>::BinarySearchT
BinarySearchTree.cpp:32:23: warning: extended initializer lists only available wiabled by default]
  BinarySearchTree() : root{ NULL }
                       ^
BinarySearchTree.cpp: In copy constructor 'BinarySearchTree<Comparable>::BinarySeomparable>&)':
BinarySearchTree.cpp:39:51: warning: extended initializer lists only available wiabled by default]
  BinarySearchTree(const BinarySearchTree & rhs) : root{ NULL }
                                                   ^
BinarySearchTree.cpp: In member function 'BinarySearchTree<Comparable>& BinarySeanarySearchTree<Comparable>)':
BinarySearchTree.cpp:75:19: error: 'rhs' was not declared in this scope
   std::swap(root, rhs.root);
                   ^
BinarySearchTree.cpp: In member function 'void BinarySearchTree<Comparable>::inse
BinarySearchTree.cpp:155:10: error: 'move' is not a member of 'std'
   insert(std::move(x), root);
          ^
BinarySearchTree.cpp:155:20: error: 'x' was not declared in this scope
   insert(std::move(x), root);
                    ^
BinarySearchTree.cpp: In constructor 'BinarySearchTree<Comparable>::BinaryNode::BrySearchTree<Comparable>::BinaryNode*, BinarySearchTree<Comparable>::BinaryNode*)
BinarySearchTree.cpp:183:6: warning: extended initializer lists only available wiabled by default]
    : element{ theElement }, left{ lt }, right{ rt } { }
      ^
BinarySearchTree.cpp:183:29: warning: extended initializer lists only available wnabled by default]
    : element{ theElement }, left{ lt }, right{ rt } { }
                             ^
BinarySearchTree.cpp:183:41: warning: extended initializer lists only available wnabled by default]
    : element{ theElement }, left{ lt }, right{ rt } { }
                                         ^
BinarySearchTree.cpp: In constructor 'BinarySearchTree<Comparable>::BinaryNode::B
BinarySearchTree.cpp:186:6: warning: extended initializer lists only available wiabled by default]
    : element{ std::move(theElement) }, left{ lt }, right{ rt } { }
      ^
BinarySearchTree.cpp:186:15: error: 'move' is not a member of 'std'
    : element{ std::move(theElement) }, left{ lt }, right{ rt } { }
               ^
BinarySearchTree.cpp:186:25: error: 'theElement' was not declared in this scope
    : element{ std::move(theElement) }, left{ lt }, right{ rt } { }
                         ^
BinarySearchTree.cpp:186:40: warning: extended initializer lists only available wnabled by default]
    : element{ std::move(theElement) }, left{ lt }, right{ rt } { }
                                        ^
BinarySearchTree.cpp:186:46: error: 'lt' was not declared in this scope
    : element{ std::move(theElement) }, left{ lt }, right{ rt } { }
                                              ^
BinarySearchTree.cpp:186:52: warning: extended initializer lists only available wnabled by default]
    : element{ std::move(theElement) }, left{ lt }, right{ rt } { }
                                                    ^
BinarySearchTree.cpp:186:59: error: 'rt' was not declared in this scope
    : element{ std::move(theElement) }, left{ lt }, right{ rt } { }
                                                           ^
BinarySearchTree.cpp: In member function 'void BinarySearchTree<Comparable>::inseComparable>::BinaryNode*&)':
BinarySearchTree.cpp:202:12: warning: extended initializer lists only available wnabled by default]
    t = new BinaryNode{ x, NULL, NULL };
            ^
BinarySearchTree.cpp: In member function 'void BinarySearchTree<Comparable>::inse
BinarySearchTree.cpp:218:7: error: 't' was not declared in this scope
   if (t == NULL)
       ^
BinarySearchTree.cpp:219:12: warning: extended initializer lists only available wnabled by default]
    t = new BinaryNode{ std::move(x), NULL, NULL };
            ^
BinarySearchTree.cpp:219:24: error: 'move' is not a member of 'std'
    t = new BinaryNode{ std::move(x), NULL, NULL };
                        ^
BinarySearchTree.cpp:219:34: error: 'x' was not declared in this scope
    t = new BinaryNode{ std::move(x), NULL, NULL };
                                  ^
BinarySearchTree.cpp:220:12: error: 'x' was not declared in this scope
   else if (x < t->element)
            ^
BinarySearchTree.cpp:221:11: error: 'move' is not a member of 'std'
    insert(std::move(x), t->left);
           ^
BinarySearchTree.cpp:223:11: error: 'move' is not a member of 'std'
    insert(std::move(x), t->right);
           ^
BinarySearchTree.cpp: In member function 'void BinarySearchTree<Comparable>::remoComparable>::BinaryNode*&)':
BinarySearchTree.cpp:243:23: error: 'nullptr' was not declared in this scope
   else if (t->left != nullptr && t->right != nullptr) // Two children
                       ^
BinarySearchTree.cpp: In member function 'BinarySearchTree<Comparable>::BinaryNodclone(BinarySearchTree<Comparable>::BinaryNode*) const':
BinarySearchTree.cpp:367:15: warning: extended initializer lists only available wnabled by default]
    return new BinaryNode{ t->element, clone(t->left), clone(t->right) };
           ^

Actually, I'm going to expand my comment into an answer.

The comment: it looks like GCC isn't building as C++11, whereas Xcode (LLVM, presumably) is. Eg see the claim that nullptr is undefined.

To force LLVM to compile as though an old fashioned C++ compiler in Xcode, open your project settings, navigate to this one:

在此处输入图片说明

... and select C++98.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM