473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

gcc flag to compiling C


how do find out what the command line flag that forces a C compilation
for my gcc 3.3.5-3, I am doing an exercise and am asked to note the
difference between C and C++ compilation of a code which uses puts()
without <stdio.h> in it.

I got on the C-h i gcc, it said in * G++ and GCC::
There is no intermediate C version of the program.
(By contrast, for example, some other implementations use a program
that generates a C program from your C++ source.)
thanks
Aug 14 '05 #1
3 6650
Baloff wrote:
how do find out what the command line flag that forces a C compilation
for my gcc 3.3.5-3, I am doing an exercise and am asked to note the
difference between C and C++ compilation of a code which uses puts()
without <stdio.h> in it.

I got on the C-h i gcc, it said in * G++ and GCC::
There is no intermediate C version of the program.
(By contrast, for example, some other implementations use a program
that generates a C program from your C++ source.)


You should post this Q to a gcc list. It's off topic here.

Anyhow, most compilers will key off the file name extension.

file.c -> C compiler

file.{cpp,c++,C,cxx,cc} -> C++ compiler
I found this by googling on "C cpp c++ cxx cc":
Compiler possible endings
GNU compiler g++ C cc cpp cxx c++
Watcom C++ -- cc cpp cxx c++
Borland C++ -- cc cpp cxx c++
SGI compiler CC C cc cpp cxx c++
DEC compiler cxx C cc cpp cxx --

However, if you're compiling a C++ program in gcc YOU MUST use "g++" for
the link phase and not gcc.

G
Aug 14 '05 #2
Baloff wrote:
how do find out what the command line flag that forces a C compilation
for my gcc 3.3.5-3, I am doing an exercise and am asked to note the
difference between C and C++ compilation of a code which uses puts()
without <stdio.h> in it.

I got on the C-h i gcc, it said in * G++ and GCC::
There is no intermediate C version of the program.
(By contrast, for example, some other implementations use a program
that generates a C program from your C++ source.)
thanks


In general:

compile and link 'C' source/obj with 'gcc'.
compile and link C++ source/obj with 'g++'.
link mixed C/C++ objs with 'g++.
Aug 14 '05 #3
Baloff wrote:

how do find out what the command line flag that forces a C compilation
for my gcc 3.3.5-3, I am doing an exercise and am asked to note the
difference between C and C++ compilation of a code which uses puts()
without <stdio.h> in it.

I got on the C-h i gcc, it said in * G++ and GCC::
There is no intermediate C version of the program.
(By contrast, for example, some other implementations use a program
that generates a C program from your C++ source.)


g++ has a command line switch -x:
-x <language> Specify the language of the following input files
Permissable languages include: c c++ assembler none
'none' means revert to the default behavior of
guessing the language based on the file's extension

so you could write 'g++ -x c exercise.cpp'

Maett
Aug 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jeremy Lemaire | last post by:
Hello, I am working on cross platform code that is displaying a huge memory leak when compiled on 11.00 HPUX using the aCC -AA flag. It is not leaking on NT, LINUX, Solaris, or HPUX without the...
42
by: Shayan | last post by:
Is there a boolean flag that can be set atomically without needing to wrap it in a mutex? This flag will be checked constantly by multiple threads so I don't really want to deal with the overhead...
2
by: Blue Man | last post by:
Hello I want to create a link that open and close a panel. but i can't save a variable as a flag to test each time if the panel is open or not, this is my code : int flag=0; private void...
1
by: Uri Dimant | last post by:
Hi,friends I meant Flag on text editor. It allows you to move from flag to flag only within one class/module. If you put another flag within different module/class in the same project then it...
3
by: Jim Archer | last post by:
Hi All... I'm been fighting this problem for a few days now, and it seems like it should be simple. But the solution has eluded me so far... I need to flag a record when it is updated or when...
2
by: Bernd Hohmann | last post by:
I need a control break flag in my result when a certain value is different to the previous. A table/result like this: PRODUCER ARTICLE 80000 1 <- flag = 1 80000 2 <- flag = 0 80000 ...
1
by: rpapaiof | last post by:
is it possible to write the same program wit same commands without flag and also please describe flag #include <stdio.h> int main(void){ int j,n,i,flag; printf("Please enter a number :...
2
by: Efi Merdler | last post by:
Hello, As I understand it is impossible in xslt to change the value of a variable after you assigned a value to it. I would like to simulate a flag. For example if something happens in template...
15
by: new to c | last post by:
Hi! I write this code cos.c #include <math.h> #include <stdio.h> int main(void) { double c;
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.