2016-01-27 34 views
5

Voglio configurare Eclipse (o Codeblocks) in modo tale che quando scrivo un passaggio, posso almeno trarre vantaggio da Intellisense (anche se la costruzione passa direttamente da Eclipse non è possibile). Aggiornamento: io sono sempre almeno alcuni intellisense una volta mi ha permesso le proposte di analisi basati su in Eclipse (dettagli sotto)Configurare Eclipse CDT o Codeblocks per ottenere LLVM IR intellisense

Finora ho configurato per utilizzare Eclipse clang per compilare semplici programmi C++.

Per ottenere intellisense per LLVM passaggio, ho aggiunto /usr/local/include-Include directory e il codice provato:

#include <iostream> 
#include <llvm/IR/Function.h> 

using namespace std: 
int main() { 
    cout << "Hello World" << endl; 
    return 0; 
} 

E non manca il #include <llvm/IR/Function.h> stesso (cioè può trovare questo file di intestazione), ma su compresi i file successivi, mi dà

/usr/local/include/llvm/Support/DataTypes.h:58:3: error: "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h" 

Qualsiasi suggerimento su come potrei farlo mi dà almeno intellisenso?

completa Log

01:22:48 **** Rebuild of configuration Debug for project HelloWorld2 **** 
Info: Internal Builder is used for build 
clang++ -I/usr/local/include -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -o src/HelloWorld2.bc ../src/HelloWorld2.cpp 
In file included from ../src/HelloWorld2.cpp:10: 
In file included from /usr/local/include/llvm/IR/Function.h:22: 
In file included from /usr/local/include/llvm/IR/Argument.h:17: 
In file included from /usr/local/include/llvm/ADT/Twine.h:14: 
/usr/local/include/llvm/Support/DataTypes.h:58:3: error: "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h" 
# error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h" 
^
/usr/local/include/llvm/Support/DataTypes.h:62:3: error: "Must #define __STDC_CONSTANT_MACROS before "   "#including Support/DataTypes.h" 
# error "Must #define __STDC_CONSTANT_MACROS before " \ 
^
In file included from ../src/HelloWorld2.cpp:10: 
In file included from /usr/local/include/llvm/IR/Function.h:22: 
In file included from /usr/local/include/llvm/IR/Argument.h:19: 
In file included from /usr/local/include/llvm/IR/Attributes.h:19: 
In file included from /usr/local/include/llvm/ADT/ArrayRef.h:14: 
In file included from /usr/local/include/llvm/ADT/SmallVector.h:20: 
/usr/local/include/llvm/Support/MathExtras.h:273:24: error: use of undeclared identifier 'INT64_C' 
    return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1))); 
        ^
/usr/local/include/llvm/Support/MathExtras.h:273:56: error: use of undeclared identifier 'INT64_C' 
    return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1))); 
                ^
/usr/local/include/llvm/Support/MathExtras.h:299:26: error: use of undeclared identifier 'UINT64_C' 
    return N >= 64 || x < (UINT64_C(1)<<(N)); 
         ^
/usr/local/include/llvm/Support/MathExtras.h:331:24: error: use of undeclared identifier 'INT64_C' 
    return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1))); 
        ^
/usr/local/include/llvm/Support/MathExtras.h:331:56: error: use of undeclared identifier 'INT64_C' 
    return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1))); 
                ^
In file included from ../src/HelloWorld2.cpp:10: 
In file included from /usr/local/include/llvm/IR/Function.h:22: 
In file included from /usr/local/include/llvm/IR/Argument.h:19: 
In file included from /usr/local/include/llvm/IR/Attributes.h:19: 
In file included from /usr/local/include/llvm/ADT/ArrayRef.h:14: 
/usr/local/include/llvm/ADT/SmallVector.h:232:20: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 
    void push_back(T &&Elt) { 
       ^
/usr/local/include/llvm/ADT/SmallVector.h:476:33: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 
    iterator insert(iterator I, T &&Elt) { 
           ^
/usr/local/include/llvm/ADT/SmallVector.h:645:46: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 
    SmallVectorImpl &operator=(SmallVectorImpl &&RHS); 
              ^
/usr/local/include/llvm/ADT/SmallVector.h:383:12: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions] 
     for (auto I = this->end(), E = this->begin() + N; I != E; ++I) 
     ^
/usr/local/include/llvm/ADT/SmallVector.h:764:70: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 
SmallVectorImpl<T> &SmallVectorImpl<T>::operator=(SmallVectorImpl<T> &&RHS) { 
                    ^
/usr/local/include/llvm/ADT/SmallVector.h:878:27: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 
    SmallVector(SmallVector &&RHS) : SmallVectorImpl<T>(N) { 
         ^
/usr/local/include/llvm/ADT/SmallVector.h:883:44: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 
    const SmallVector &operator=(SmallVector &&RHS) { 
             ^
In file included from ../src/HelloWorld2.cpp:10: 
In file included from /usr/local/include/llvm/IR/Function.h:22: 
In file included from /usr/local/include/llvm/IR/Argument.h:19: 
In file included from /usr/local/include/llvm/IR/Attributes.h:20: 
In file included from /usr/local/include/llvm/ADT/FoldingSet.h:21: 
/usr/local/include/llvm/Support/Allocator.h:134:70: error: expected expression 
      BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold>> { 
                    ^
/usr/local/include/llvm/Support/Allocator.h:346:2: error: expected a type 
}; 
^ 
/usr/local/include/llvm/Support/Allocator.h:346:2: error: expected class name 
/usr/local/include/llvm/Support/Allocator.h:346:2: error: expected '{' after base class list 
/usr/local/include/llvm/Support/Allocator.h:362:53: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 
    SpecificBumpPtrAllocator(SpecificBumpPtrAllocator &&Old) 
                ^
/usr/local/include/llvm/Support/Allocator.h:366:64: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 
    SpecificBumpPtrAllocator &operator=(SpecificBumpPtrAllocator &&RHS) { 
                  ^
/usr/local/include/llvm/Support/Allocator.h:375:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions] 
    auto DestroyElements = [](char *Begin, char *End) { 
    ^
/usr/local/include/llvm/Support/Allocator.h:375:28: error: expected expression 
    auto DestroyElements = [](char *Begin, char *End) { 
         ^
/usr/local/include/llvm/Support/Allocator.h:381:10: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions] 
    for (auto I = Allocator.Slabs.begin(), E = Allocator.Slabs.end(); I != E; 
     ^
/usr/local/include/llvm/Support/Allocator.h:381:29: error: no member named 'Slabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>' 
    for (auto I = Allocator.Slabs.begin(), E = Allocator.Slabs.end(); I != E; 
        ~~~~~~~~~^
/usr/local/include/llvm/Support/Allocator.h:381:58: error: no member named 'Slabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>' 
    for (auto I = Allocator.Slabs.begin(), E = Allocator.Slabs.end(); I != E; 
               ~~~~~~~~~^
/usr/local/include/llvm/Support/Allocator.h:383:52: error: no member named 'computeSlabSize' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>' 
     size_t AllocatedSlabSize = BumpPtrAllocator::computeSlabSize(
           ~~~~~~~~~~~~~~~~~~^ 
/usr/local/include/llvm/Support/Allocator.h:384:35: error: no member named 'Slabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>' 
      std::distance(Allocator.Slabs.begin(), I)); 
         ~~~~~~~~~^
/usr/local/include/llvm/Support/Allocator.h:386:35: error: no member named 'Slabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>' 
     char *End = *I == Allocator.Slabs.back() ? Allocator.CurPtr 
         ~~~~~~~~~^
/usr/local/include/llvm/Support/Allocator.h:386:60: error: no member named 'CurPtr' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>' 
     char *End = *I == Allocator.Slabs.back() ? Allocator.CurPtr 
               ~~~~~~~~~^
/usr/local/include/llvm/Support/Allocator.h:392:10: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions] 
    for (auto &PtrAndSize : Allocator.CustomSizedSlabs) { 
     ^
/usr/local/include/llvm/Support/Allocator.h:392:39: error: no member named 'CustomSizedSlabs' in 'llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096>' 
    for (auto &PtrAndSize : Allocator.CustomSizedSlabs) { 
          ~~~~~~~~~^
/usr/local/include/llvm/Support/Allocator.h:392:27: warning: range-based for loop is a C++11 extension [-Wc++11-extensions] 
    for (auto &PtrAndSize : Allocator.CustomSizedSlabs) { 
         ^
fatal error: too many errors emitted, stopping now [-ferror-limit=] 
13 warnings and 20 errors generated. 

01:22:50 Build Finished (took 1s.509ms) 

UPDATE: Eclipse mi fa dare Intellisense (almeno una parte di esso), ho dovuto controllare le proposte di analisi basati su in Finestra -> Preferenze -> C/C++ -> Editor -> Content Assist -> Advanced (era deselezionato per impostazione predefinita).

risposta

1

Questo non risponde direttamente alla domanda, ma garantisce che si dispone di un ambiente di compilazione correttamente funzionante. È specifico per i blocchi di codice.

Prima cassa l'albero dei sorgenti di LLVM (direttamente tratto dalla guida introduttiva guide):

git clone http://llvm.org/git/llvm.git 
cd llvm/tools 
git clone http://llvm.org/git/clang.git 
cd .. 
cd projects 
git clone http://llvm.org/git/compiler-rt.git 
git clone http://llvm.org/git/libcxx.git 
git clone http://llvm.org/git/libcxxabi.git 
git clone http://llvm.org/git/test-suite.git 
git clone http://llvm.org/git/openmp.git 

rimuovere tutto ciò che non ti piace.

Quindi creare una directory al di fuori della directory LLVM:

cd .. 
mkdir build 

modificare la directory (cd) a lì ed eseguire:

cd build 
cmake -g "CodeBlocks - Unix Makefiles" <your configure options> ../llvm 

Supponendo azioni LLVM il percorso principale, altrimenti cambia il ../llvm linea per il percorso corretto. Quindi aprilo come un progetto esistente in code :: blocks.

Se tutto è andato bene, l'ambiente di compilazione è configurato correttamente e il completamento del codice dovrebbe funzionare.

+0

Grazie @ edgar-klerks, Anche se potrebbe non rispondere direttamente alla domanda, risolve un problema correlato, lo accetto. – ishaq