LINUX.ORG.RU

gcc g++


0

0

Доброго времяни суток!

Почему у меня g++ видит iostream, а gcc нет?

Какой компилятор лучше юзать для c++?

anonymous

А еще cin и cout не работает.

g++ ругается что такой функции нет.

#include <iostream>

anonymous
()

gcc это с g++ это С++ .. iostream Это С++. ... stdio(printf scanf) это С

anonymous
()

g++ и есть компилятор С++, следовательно его и _нужно_ юзать.

stassats ★★★★
()

gcc решает какой компилятор использовать в зависимости от разширения исходника

man 1 gcc

       ---[cut]---
       For any given input file, the file name suffix determines
       what kind of compilation is done:

       file.c
           C source code which must be preprocessed.

       file.i
           C source code which should not be preprocessed.

       file.ii
           C++ source code which should not be preprocessed.

       file.m
           Objective-C source code.  Note that you must link with
           the library libobjc.a to make an Objective-C program
           work.

       file.mi
           Objective-C source code which should not be prepro-
           cessed.

       file.h
           C header file (not to be compiled or linked).

       file.cc
       file.cp
       file.cxx
       file.cpp
       file.c++
       file.C
           C++ source code which must be preprocessed.  Note that
           in .cxx, the last two letters must both be literally
           x.  Likewise, .C refers to a literal capital C.

       file.f
       file.for
       file.FOR
           Fortran source code which should not be preprocessed.

       file.F
       file.fpp
       file.FPP
           Fortran source code which must be preprocessed (with
           the traditional preprocessor).
       ---[cut]---

anonymous
()
Ответ на: комментарий от anonymous

Так у него нигде не указано какое он расширение использует (наверняка .c), а в iostream.h, всетаки КЛАССЫ для работы с потоковым вводом-выводом лежат.

1) Меняй компилятор
2) Пробуй задать другое расширение файла.

r_asian ★☆☆
()
Ответ на: комментарий от anonymous

>gcc решает какой компилятор использовать в зависимости от разширения исходника

Если использовать gcc для сборки С++ программ, придется руками указвать ему -lstdc++ (-lg++ в ранних версиях). С g++ такой проблемы нет.

Так что лучше для С - gcc для С++ - g++.

Vinick ★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.