Jump to content
Sign in to follow this  
gte

Favorite c++ compiler?

Recommended Posts

gte

I'm learning c++ now, and have had ridiculous time wasting problems, related to includes mostly, with VS2008 for c++. I can now really appreciate the time spent in making the AIT includes pretty much flawless.

Just wondering if that's common place, and if anyone has a better IDE/compiler to recommend for me to use? It appears that scite can be used with c++, and I love scite with AIT, does anyone have experience using it with c++?

The only api that did not have a broken download link here

http://groups.google.com/group/scite-interest/web/extras

was the windows api.

Thanks for reading, I'd love to hear first hand experiences.

Share this post


Link to post
Share on other sites
Valik

get, if you're having trouble with an IDE that does a lot of the work for you then you're going to struggle even more mightily with SciTE where you essentially have to do everything yourself. You'd be better served to post whatever problems you are having and let others point you in the right direction.

Share this post


Link to post
Share on other sites
danielkza

I tried diff. IDEs (NetBeans, Eclipse and DevC++, precisely), and Visual Studio beat them all. And all of them are orders of magnitude ahead of SciTE, specially if you want assistance (autocompleting, IntelliSense, etc) while you code.

One thing I can suggest (if you didn't know it already), is joining StackOverflow. You'll find answers to pretty much every problem you have (specially when you're starting to grasp a language or programming in general). The reputation system works quite well: I have not seen any instance of trolling whatsoever, and the community is very friendly to newcomers.

Share this post


Link to post
Share on other sites
bo8ster

Read this


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites
gte

The troubles I have with VS is with includes. Just about every include that I add fails and requires a ton of work to try and get it to compile without include errors. For some reason stdafx wouldn't compile right the other day?

With the AIT help file (which I love, thank you!) and Scite, I've never had an include issue, it tells you which include you need, if you need one, and I add it and it compiles. With VS, there is no help file, and I have a choice of starting a dozen or so projects. I try and always pick an empty console application (since I am learning) and I seem to always have include/compile errors. Would you like me to go back through my starter projects and see if I can generate another error and post the specific error?

get, if you're having trouble with an IDE that does a lot of the work for you then you're going to struggle even more mightily with SciTE where you essentially have to do everything yourself. You'd be better served to post whatever problems you are having and let others point you in the right direction.

Share this post


Link to post
Share on other sites
monoceres

Building stuff in C++ is a way more complex process than in most languages. This is because C++ makes use of separate compilation. Lack of understanding of that process almost always results in failure when trying to make use of anything but standard C++.

Describing how it works and why is to much to describe in this one post, so go grab a book or something. However I will say one thing, just because you include something doesn't mean you have access to the library, it means you have the description of the library (open a .h file to see for yourself, it just contains declarations!).

However an empty console project is almost to easy in Visual Studio, New->Project->Win32->Win32 Console Application.

When the project is created just add a .cpp file to the project and write your code in it, don't forget int main().


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
Valik

The troubles I have with VS is with includes. Just about every include that I add fails and requires a ton of work to try and get it to compile without include errors.

Then you must have a configuration issue or you don't understand the difference between C++'s #include <> and #include "".

For some reason stdafx wouldn't compile right the other day?

Magic 8 ball says, "That's not helpful information". Why wouldn't it compile? A pre-compiled header won't compile if you're struggling to use #include right in the first place since... well it's based on optimizing the compile time of static #include statements.

With VS, there is no help file

Yes it does. Visual Studio 2005, 2008 and 2010 install a light version of MSDN. You can freely download the full version of MSDN from the internets. Search on Microsoft's site for "MSDN Library" and download and install the appropriate version for your version of Visual Studio.

Share this post


Link to post
Share on other sites
gte

Ok

Here is an example of another include error, it's failing at this line #include <iostream>, I believe it's trying to tell me that it doesn't recognize this include?

error C2447: '{' : missing function header (old-style formal list?)

// module4.cpp : main project file.
//
#include "stdafx.h"

using namespace System;
//
//int main(array<System::String ^> ^args)
//{
//    Console::WriteLine(L"Hello World");
//    return 0;
//}









/****************************************************/
/* File: name of your file with the source code     */
/*                                                  */
/* Created by: give your name                       */
/* Date: give the date                              */
/*                                                  */
/* Program to compute binomial coefficients         */
/*                                                  */
/* Inputs: (keyboard)                               */
/*   Two positive integers (n & k)                  */
/*                                                  */
/* Output:                                          */
/*   Corresponding binomial coefficient (nCk)       */
/*                                                  */
/* Algorithm: see attached description              */
/****************************************************/

#include <iostream>

using namespace std ;

int binomial(int n, int k) ; // function prototype

int main()
{

   int n, k ;   // parameters for the binomial number
   int result ;  

   cout << endl ;

   // read in n & k  

   cout << "Enter n (positive integer) :  " ;
   cin >> n ;

   cout << "Enter k (positive integer) : " ;
   cin >> k ;

   // result = Write the function call ;

   cout << "Binomial number " << n << "Choose" << k
        << " = " << result << endl ;

   return (0) ;
}

// ********************************************************

int binomial(int n, int k) ;

/* Computes the binomial coefficient nCk */
/* */
/* Inputs:                               */
/*    n, k (integers)                    */
/*                                       */
/* Output:                               */
/*    binomial coefficient nCk (integer) */

 {
   int numerator, denominator ;
   int i ; // needed to compute numerator & denominator

   if ( k < n ) // Write if-test
   {
     return( 0 ) ; 
     cout << "Value 'k' cannot be larger than value 'n'" << endl ; // Write return value
   }
   else 
   {
      denominator =  k  ; // Write initial value

      for (i = 1; i <= k; i = i+1)

        denominator = k * (k-i)   ;
        cout << k << endl ;

        // Write code to compute numerator, along similar lines
         

        
      return ( k ) ; //Write return value
   }
 }

Share this post


Link to post
Share on other sites
Valik

And the contents of Stdafx.h are?

Share this post


Link to post
Share on other sites
gte

By right clicking on it and choosing view code, this is what came about:

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

// TODO: reference additional headers your program requires here

Share this post


Link to post
Share on other sites
Richard Robertson

The problem is this section.

int binomial(int n, int k) ;

/* Computes the binomial coefficient nCk */
/* */
/* Inputs:                               */
/*    n, k (integers)                    */
/*                                       */
/* Output:                               */
/*    binomial coefficient nCk (integer) */

 {

You've got a semicolon after the function name, so the { is wrong.

Share this post


Link to post
Share on other sites
gte

Thanks Richard!

The code from the assignment actually had that in it? :)

So whenever you declare function name, you do not follow it with a semicolon?

The problem is this section.

int binomial(int n, int k) ;

/* Computes the binomial coefficient nCk */
/* */
/* Inputs:                               */
/*    n, k (integers)                    */
/*                                       */
/* Output:                               */
/*    binomial coefficient nCk (integer) */

 {

You've got a semicolon after the function name, so the { is wrong.

Share this post


Link to post
Share on other sites
Richard Robertson

When you declare a function it must be followed by either a semicolon or a method body. Both are valid but not at the same time.

Share this post


Link to post
Share on other sites
gte

Geez, I just do not understand this language or its includes? There has to be some large thing that I am missing, that allows for includes to work? There is no way everyone that tries to learn c++ has these problems?

Depending on if I try and predefine it

1>module4.obj : error LNK2028: unresolved token (0A0002BC) "int __cdecl factorial(int)" (?factorial@@$$FYAHH@Z) referenced in function "int __cdecl binomial(int,int)" (?binomial@@$$FYAHHH@Z)

1>module4.obj : error LNK2019: unresolved external symbol "int __cdecl factorial(int)" (?factorial@@$$FYAHH@Z) referenced in function "int __cdecl binomial(int,int)" (?binomial@@$$FYAHHH@Z)

or not

error C3861: 'factorial': identifier not found

#include "stdafx.h" 
using namespace System; 
#include <iostream> 
using namespace std ; 


int binomial(int n, int k) ; // function prototype 
int factorial(int z) ;
int main() 
    {
        int n, k ; // parameters for the binomial number 
        int result ; 
        cout << endl ;
// read in n & k cout << 
        "Enter n (positive integer) : " ; 
        cin >> n ;
        cout << "Enter k (positive integer) : " ; 
        cin >> k ;
// result = Write the function call ; 
        cout << "Binomial number " << n << "Choose" << k << " = " << result << endl ; 
        return (0) ; 
    }
// ********************************************************
        int binomial(int n, int k) /* Computes the binomial coefficient nCk */
/* */
/* Inputs: */
/* n, k (integers) */
/* */
/* Output: */
/* binomial coefficient nCk (integer) */
{
        int numerator, denominator ; 
        int i ; // needed to compute numerator & denominator 
        if ( k < n ) // Write if-test 
    {   
        return( 0 ) ; 
        cout << "Value 'k' cannot be larger than value 'n'" << endl ; // Write return value 
    }
    else 
    {
    denominator = k ; 
// Write initial value 
        for (i = 1; i <= k; i = i+1) 
        denominator = (k * factorial (k-1)) ;
        cout << k << endl ;
// Write code to compute numerator, along similar lines 
        return ( k ) ; //Write return value 
    }
}

Share this post


Link to post
Share on other sites
Valik

The function factorial() is declared but never defined. If you declare it but give it no body then the linker will throw an error because it can't find the function body to link to. If you don't declare it then the compiler doesn't know what you're talking about.

Are you sure you are ready for this? You seem to be missing some very fundamental basics. Are you reading a book or trying to piece stuff together from tutorials?

Edit: Also, why are you using "using namespace System"? It almost seems like you have copied some C# or managed C++ code and are trying to use that but you aren't compiling with CLR on.

Edited by Valik

Share this post


Link to post
Share on other sites
gte

I definitely don't feel ready for this, the book they have for my class is written in psuedocode, and poorly written at that, but I'm not one to give up easily and I'm hoping through determination and the help of more experienced people such as yourself, I'll be able to pick this up. I know that my problems with the compiler are problems with me, and not problems of the compiler, which is good in a way, because I have control over the problems with me.

I thought that factorial was a built in function (like "return") and not a function that I had to write, but if I am understanding you correctly, it sounds as if it is not.

My assignment gave me the following, and this is the unaltered starting code that they want you to modify. Let me know what you think about it. I did add a few things that I found in researching on the web (because the text book is written in psuedocode so I can't use that) and maybe that's where my problem is?

/****************************************************/
/* File: name of your file with the source code     */
/*                                                  */
/* Created by: give your name                       */
/* Date: give the date                              */
/*                                                  */
/* Program to compute binomial coefficients         */
/*                                                  */
/* Inputs: (keyboard)                               */
/*   Two positive integers (n & k)                  */
/*                                                  */
/* Output:                                          */
/*   Corresponding binomial coefficient (nCk)       */
/*                                                  */
/* Algorithm: see attached description              */
/****************************************************/

#include <iostream>

using namespace std ;

int binomial(int n, int k) ; // function prototype

int main()
{

   int n, k ;   // parameters for the binomial number
   int result ;  

   cout << endl ;

   // read in n & k  

   cout << "Enter n (positive integer) :  " ;
   cin >> n ;

   cout << "Enter k (positive integer) : " ;
   cin >> k ;

   result = Write the function call ;

   cout << "Binomial number " << n << "C" << k
        << " = " << result << endl ;

   return (0) ;
}

// ********************************************************

int binomial(int n, int k)

/* Computes the binomial coefficient nCk */
/* */
/* Inputs:                               */
/*    n, k (integers)                    */
/*                                       */
/* Output:                               */
/*    binomial coefficient nCk (integer) */

{
   int numerator, denominator ;
   int i ; // needed to compute numerator & denominator

   if (  ) Write if-test
   {
     return(  ) ; Write return value
   }
   else 
   {
      denominator =    ; Write initial value

      for (i =    ; i <=    ; i = i+1)
        denominator =    *    ;
        Write code to compute numerator, along similar lines

      return (  ) ; Write return value
   }
}

The function factorial() is declared but never defined. If you declare it but give it no body then the linker will throw an error because it can't find the function body to link to. If you don't declare it then the compiler doesn't know what you're talking about.

Are you sure you are ready for this? You seem to be missing some very fundamental basics. Are you reading a book or trying to piece stuff together from tutorials?

Edit: Also, why are you using "using namespace System"? It almost seems like you have copied some C# or managed C++ code and are trying to use that but you aren't compiling with CLR on.

Share this post


Link to post
Share on other sites
bo8ster

Geez, I just do not understand this language or its includes? There has to be some large thing that I am missing, that allows for includes to work? There is no way everyone that tries to learn c++ has these problems?

Apart from what Valik said it is clear you have not learnt from a book. The ordering includes, comments and general layout is not common to an example you would find.

Example: I would expect see includes to be listed like:

using namespace System; 
using namespace std ; 
#include <iostream> 
#include "stdafx.h"

Understanding what each line does goes a long way to understanding why I would list them in that order.

There is a thread here and here that have some good links. Understand the basics first then you will understand the compiler more - as my lecture always said "the compiler is always right" - it was annoying but you learn :)

Edit: Just saw your last post - the factorial function is not built in, in fact there is only a handful of key works in C++, the rest is made up by libraries. Help files give you the contents of the libraries and over time you remember them. Example: cout is not apart of C++ like return is, it is apart of the iostream library which you included at the top of the file.

Edited by bo8ster

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites
turbov21

I don't do much C++, and when I do it's usually on a Linux system, so I have to say g++. Not a very educated recommendation, I'm afraid, but it and gcc have never let me down.

Edited by turbov21

Share this post


Link to post
Share on other sites
bo8ster

I don't do much C++, and when I do it's usually on a Linux system, so I have to say g++. Not a very educated recommendation, I'm afraid, but it and gcc have never let me down.

I understand gcc and g++ are the same, thus g++ uses gcc.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites
gte

Looking in the help file for "factorial c++" lends results to the below, and what's confusing about this, is that there is no includes, and it appears that it's calling the function factorial inside of itself, without ever really defining it?

int factorial( int num );      /* Function prototype */

void main()
{
    int result, number;
    .
    .
    .
    result = factorial( number );
}

int factorial( int num )      /* Function definition */
{
    .
    .
    .
    if ( ( num > 0 ) || ( num <= 10 ) )
        return( num * factorial( num - 1 ) );
}

Apart from what Valik said it is clear you have not learnt from a book. The ordering includes, comments and general layout is not common to an example you would find.

Example: I would expect see includes to be listed like:

using namespace System; 
using namespace std ; 
#include <iostream> 
#include "stdafx.h"

Understanding what each line does goes a long way to understanding why I would list them in that order.

There is a thread here and here that have some good links. Understand the basics first then you will understand the compiler more - as my lecture always said "the compiler is always right" - it was annoying but you learn :)

Edit: Just saw your last post - the factorial function is not built in, in fact there is only a handful of key works in C++, the rest is made up by libraries. Help files give you the contents of the libraries and over time you remember them. Example: cout is not apart of C++ like return is, it is apart of the iostream library which you included at the top of the file.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.