Re: is possible create a any type variable(1 variable that accept any type of values)
Quote:
Originally Posted by
Paul McKenzie
I've mentioned to you on other threads that the compiler used by Dev-C++ and MingW is what is important. That compiler happens to be gcc.
The gcc compiler already supports everything that you are looking for.
http://gcc.gnu.org/projects/cxx0x.html
MingW also uses gcc to compile projects. Dev-C++ (once again) is an IDE that just happens to have an
old version of gcc already plugged into it. If you take a look at the link I gave you above, and do a little searching on the Internet, you should be able to upgrade MingW to use the latest version of gcc.
The boost libraries are extensively tested with gcc and Visual Studio, and I would say the two platforms that
must compile successfully before being accepted by boost.org.
As to IDE's, there is CodeBlocks, which is up-to-date. Do an Intenet search and you will find other IDE's.
Regards,
Paul McKenzie
seems that i didn't understand that before..thanks
1 thing: the CodeBlocks suports C++11?
Re: is possible create a any type variable(1 variable that accept any type of values)
Quote:
Originally Posted by
Cambalinho
seems that i didn't understand that before..thanks
1 thing: the CodeBlocks suports C++11?
You're still confused.
CodeBlocks is an Integrated Development Environment. It is not a compiler. CodeBlocks, Dev-C++, and even Visual Studio do not know how to compile C++ source code. What does know how to compile C++ source code is the underlying compiler that is used in these programs.
For CodeBlocks, you can basically plug any compiler into it, but most of the time, people configure CodeBlocks to use MingW or gcc. The latest version of gcc is 4.8 (I believe), and it supports all that have been mentioned to you so far.
For Dev-C++, it was designed for gcc 3.x, which is close to 10 years old and out-of-date. Version 3.x of gcc is ok if you're purely interested in only C++ 98 standard, but anything beyond that, 3.x is not going to help you.
For Visual Studio, the compiler used is cl.exe (and cl.exe is being updated to keep up to the current standard (C++ 11). I've heard of Intel compiler being able to be plugged into the Visual Studio IDE, but have never tried it.
Basically what I'm saying to you is that every IDE that I know of uses 2 or 3 executables:
1) The compiler that compiles the source code to object code (gcc.exe, cl.exe, etc.)
2) The linker program that links the various object code (ld.exe, link.exe, etc.)
3) A debugger program or module that allows you to debug the program (gdb.exe, ddd.exe, Visual Studio's integrated debugger, etc.).
Optionally, an IDE may just build a "make" file and call a program that knows how to read the make file and build the program.
Except for 3), where the IDE needs to understand the debugger symbols and position the debugger indicator on the correct line, items 1) and 2) requires just calling the executable that compiles and then links.
As a matter of fact, you don't even need an IDE to develop a program. The reason why IDE's are used is that using the command-line for very large projects becomes very difficult to maintain (unless you have batch files to compile and link large projects, and some people/companies do just that, and that is to create batch files/make files and forget about IDE's to build their programs).
Regards,
Paul McKenzie
Re: is possible create a any type variable(1 variable that accept any type of values)
Quote:
Originally Posted by
Paul McKenzie
You're still confused.
CodeBlocks is an Integrated Development Environment. It is not a compiler. CodeBlocks, Dev-C++, and even Visual Studio do not know how to compile C++ source code. What does know how to compile C++ source code is the underlying compiler that is used in these programs.
For CodeBlocks, you can basically plug any compiler into it, but most of the time, people configure CodeBlocks to use MingW or gcc. The latest version of gcc is 4.8 (I believe), and it supports all that have been mentioned to you so far.
For Dev-C++, it was designed for gcc 3.x, which is close to 10 years old and out-of-date. Version 3.x of gcc is ok if you're purely interested in only C++ 98 standard, but anything beyond that, 3.x is not going to help you.
For Visual Studio, the compiler used is cl.exe (and cl.exe is being updated to keep up to the current standard (C++ 11). I've heard of Intel compiler being able to be plugged into the Visual Studio IDE, but have never tried it.
Basically what I'm saying to you is that every IDE that I know of uses 2 or 3 executables:
1) The compiler that compiles the source code to object code (gcc.exe, cl.exe, etc.)
2) The linker program that links the various object code (ld.exe, link.exe, etc.)
3) A debugger program or module that allows you to debug the program (gdb.exe, ddd.exe, Visual Studio's integrated debugger, etc.).
Optionally, an IDE may just build a "make" file and call a program that knows how to read the make file and build the program.
Except for 3), where the IDE needs to understand the debugger symbols and position the debugger indicator on the correct line, items 1) and 2) requires just calling the executable that compiles and then links.
As a matter of fact, you don't even need an IDE to develop a program. The reason why IDE's are used is that using the command-line for very large projects becomes very difficult to maintain (unless you have batch files to compile and link large projects, and some people/companies do just that, and that is to create batch files/make files and forget about IDE's to build their programs).
Regards,
Paul McKenzie
thanks for all... tomorrow i will see that, thanks for all..thanks
Re: is possible create a any type variable(1 variable that accept any type of values)
i download the CodeBlocks but didn't came with compiler:(
i'm trying download the gcc, but i can't find the right download. can you help me?
it's only 1 exe or others anotherone for windows programing?
Re: is possible create a any type variable(1 variable that accept any type of values)
Quote:
Originally Posted by
Cambalinho
i download the CodeBlocks but didn't came with compiler:(
i'm trying download the gcc, but i can't find the right download. can you help me?
it's only 1 exe or others anotherone for windows programing?
As per Pauls useful detailed explanation in post #17, CodeBlocks is not a compiler and doesn't come with a compiler.:rolleyes: You are confusing an IDE (such as CodeBlocks) with the compiler (such as gcc).
The IDE allows you to create and modify your source code and calls the specified compiler/linker with the required options when needed.
The compiler (eg gcc) compiles the source code and produces object (.obj) files.
The linker takes these .obj files (and other files such as .lib files etc) and produces the .exe file.
To install gcc 4.8.1 under windows I suggest you have a look at these links for info.
http://www.cplusplus.com/forum/windows/106380/
(the second post gives links to the 32 or 64 bit windows version)
http://stackoverflow.com/questions/1...-windows-7-x64
Re: is possible create a any type variable(1 variable that accept any type of values)
Quote:
Originally Posted by
2kaud
As per Pauls useful detailed explanation in post #17, CodeBlocks is not a compiler and doesn't come with a compiler.:rolleyes: You are confusing an IDE (such as CodeBlocks) with the compiler (such as gcc).
The IDE allows you to create and modify your source code and calls the specified compiler/linker with the required options when needed.
The compiler (eg gcc) compiles the source code and produces object (.obj) files.
The linker takes these .obj files (and other files such as .lib files etc) and produces the .exe file.
To install gcc 4.8.1 under windows I suggest you have a look at these links for info.
http://www.cplusplus.com/forum/windows/106380/
(the second post gives links to the 32 or 64 bit windows version)
http://stackoverflow.com/questions/1...-windows-7-x64
thanks for all
i have more questions, but i must do another topic;)
thanks for all
Re: is possible create a any type variable(1 variable that accept any type of values)
Quote:
Originally Posted by Cambalinho
i download the CodeBlocks but didn't came with compiler
Quote:
Originally Posted by 2kaud
CodeBlocks is not a compiler and doesn't come with a compiler.
Actually, some of the official packages of CodeBlocks do come with a compiler, in particular some version of the MinGW port of GCC for two of the Windows installation packages: CodeBlocks binary packages.
Re: is possible create a any type variable(1 variable that accept any type of values)
Quote:
Originally Posted by
laserlight
Actually, some of the official packages of CodeBlocks do come with a compiler, in particular some version of the MinGW port of GCC for two of the Windows installation packages:
CodeBlocks binary packages.
now the IDE is working normaly;)
1 - dowload the IDE;
2 - download MinGW compiler;
(more easy for have the last version;))
3 - now we must 'tell' the IDE where is the compiler and choose the folders where is it. and tell it the files names inclued the compiler too;)
now i need ask something: these code works fine with C++ 11???
Code:
#include <algorithm>
#include <typeinfo>
class BaseHolder
{
public:
virtual ~BaseHolder(){}
};
template<typename T>
class HoldData : public BaseHolder
{
public:
HoldData(const T& t_) : t(t_){}
private:
T t;
};
class variant
{
public:
template<typename T>
Variant(const T& t) : data(new HoldData<T>(t)){}
~Variant(){delete data;}
private:
BaseHolder* data;
};
because i'm geting some errors in these lines:
Code:
Variant(const T& t) : data(new HoldData<T>(t)){}
~Variant(){delete data;}
or do i need do more changes in options?
Re: is possible create a any type variable(1 variable that accept any type of values)
i found the error(C is case sensitive lol):
Code:
class variant {
public:
// construct/copy/destruct
variant();
variant(const variant &);
variant(variant &&);
template<typename ValueType> variant(const ValueType &);
template<typename ValueType> variant(ValueType &&);
variant & operator=(const variant &);
variant & operator=(variant &&);
template<typename ValueType> variant & operator=(const ValueType &);
template<typename ValueType> variant & operator=(ValueType &&);
~variant();
// modifiers
variant & swap(variant &);
// queries
bool empty() const;
const std::type_info & type() const;
};
these code don't give me errors... but when i use it:
Code:
/Write
void Write(variant var1, variant var2="", variant var3="", variant var4="", variant var5="", variant var6="")
{
cout << var1 << var2 << var3 << var4 << var5 << var6;
}
i get 3 errors:
1 - "In member function 'void Console::Write(variant, variant, variant, variant, variant, variant)'";
2 - "|169|error: cannot bind 'std::ostream {aka std::basic_ostream<char>}' lvalue to 'std::basic_ostream<char>&&'|";
3 - "|error: initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = variant]'||".
what i'm doing wrong?
Re: is possible create a any type variable(1 variable that accept any type of values)
Quote:
or do i need do more changes in options?
See http://gcc.gnu.org/projects/cxx0x.html
You might need the -std=c++11 option
Re: is possible create a any type variable(1 variable that accept any type of values)
Quote:
Originally Posted by
2kaud
i think now it's selected:
in menu: Settings - Compiler...
then in Compiler Settings tab - Compiler flags sub tab i select(in all categories):
"have g++ follow the coming c++0x ISO c++ language standard [-std=c++0x]"
and
"have g++ follow the c++11 ISO c++ language standard [-std=c++11]"
it's ok, right?
(see my last post too, please)
Re: is possible create a any type variable(1 variable that accept any type of values)
You probably should choose only one of them, depending on the version of g++. I think 4.7 uses -std=c++11 whereas earlier versions use -std=c++0x (as C++11 had not been published at the time).
Re: is possible create a any type variable(1 variable that accept any type of values)
Quote:
Originally Posted by
laserlight
You probably should choose only one of them, depending on the version of g++. I think 4.7 uses -std=c++11 whereas earlier versions use -std=c++0x (as C++11 had not been published at the time).
i use MinGWx32-4.8.1;)
but if i do change it for only -std=c++11, the errors continue, when i use variant variables:(
Re: is possible create a any type variable(1 variable that accept any type of values)
Quote:
Code:
//Write
void Write(variant var1, variant var2="", variant var3="", variant var4="", variant var5="", variant var6="")
{
cout << var1 << var2 << var3 << var4 << var5 << var6;
}
i get 3 errors:
Quite right! In c++, stream insertion (<<) is done via operator overloading of the << operator. By default, << operator overloads are provided for the in-built types (int, char *etc ) and for the string class. If you want to output data from your own type or class (eg variant) then you will need to supply your own version of the << operator that works for that type/class. If you want cout to work with the class variant, then you will need something like this
Code:
//IO stream insertion (output)
ostream& operator <<(ostream& os, const variant& vt)
{
//code to go here to output data from vt as required
return (os);
}
Re: is possible create a any type variable(1 variable that accept any type of values)
Now that you have a c++11 compiler, you might want to revisit where all this started - How can I convert write procedure to cout
http://forums.codeguru.com/showthrea...cedure-to-cout
and see my post #15 with the solution using variadic templates. As gcc 4.8.1 supports variadic templates, this code should compile and give you the write function you originally wanted without using the variant class - which I suspect is going to give more trouble than it's worth:eek:.
Code:
#include <iostream>
using namespace std;
void write()
{
cout << " ";
}
template <typename A, typename ...B>
void write(A argHead, B... argTail)
{
cout << argHead << " ";
write(argTail...);
}
int main(void)
{
write(1, 2, "qwerty", 4.45, "five", 6);
return 0;
}