Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #60611 > unrolled thread

Getting Started with C; Terminal does not compile my file

Started byAlla _ <modelling.data@gmail.com>
First post2015-04-21 00:31 -0700
Last post2015-04-26 14:53 -0700
Articles 20 on this page of 42 — 14 participants

Back to article view | Back to comp.lang.c


Contents

  Getting Started with C; Terminal does not compile my file Alla _ <modelling.data@gmail.com> - 2015-04-21 00:31 -0700
    Re: Getting Started with C; Terminal does not compile my file Noob <root@127.0.0.1> - 2015-04-21 11:38 +0200
    Re: Getting Started with C; Terminal does not compile my file Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-21 11:12 +0100
    Re: Getting Started with C; Terminal does not compile my file Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-21 06:21 -0700
      Re: Getting Started with C; Terminal does not compile my file Greg Martin <greg.at.softsprocket@dot.com> - 2015-04-21 13:35 +0000
      Re: Getting Started with C; Terminal does not compile my file gazelle@shell.xmission.com (Kenny McCormack) - 2015-04-21 13:38 +0000
      Re: Getting Started with C; Terminal does not compile my file Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-21 14:44 +0100
      Re: Getting Started with C; Terminal does not compile my file Keith Thompson <kst-u@mib.org> - 2015-04-21 08:45 -0700
        Re: Getting Started with C; Terminal does not compile my file Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-22 05:35 -0700
          Re: Getting Started with C; Terminal does not compile my file Keith Thompson <kst-u@mib.org> - 2015-04-22 10:20 -0700
          Re: Getting Started with C; Terminal does not compile my file Keith Thompson <kst-u@mib.org> - 2015-04-22 10:17 -0700
            Re: Getting Started with C; Terminal does not compile my file Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-22 12:56 -0700
              Re: Getting Started with C; Terminal does not compile my file Keith Thompson <kst-u@mib.org> - 2015-04-22 13:28 -0700
                Re: Getting Started with C; Terminal does not compile my file Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-22 14:23 -0700
                  Re: Getting Started with C; Terminal does not compile my file Bartc <bc@freeuk.com> - 2015-04-22 22:39 +0100
                    Re: Getting Started with C; Terminal does not compile my file gazelle@shell.xmission.com (Kenny McCormack) - 2015-04-22 21:45 +0000
                      Re: Getting Started with C; Terminal does not compile my file Bartc <bc@freeuk.com> - 2015-04-23 01:28 +0100
                    Re: Getting Started with C; Terminal does not compile my file David Brown <david.brown@hesbynett.no> - 2015-04-23 09:30 +0200
                      Re: Getting Started with C; Terminal does not compile my file Melzzzzz <mel@zzzzz.com> - 2015-04-23 10:38 +0200
                        Re: Getting Started with C; Terminal does not compile my file David Brown <david.brown@hesbynett.no> - 2015-04-23 13:44 +0200
                  Re: Getting Started with C; Terminal does not compile my file Keith Thompson <kst-u@mib.org> - 2015-04-22 18:15 -0700
                  Re: Getting Started with C; Terminal does not compile my file David Brown <david.brown@hesbynett.no> - 2015-04-23 09:33 +0200
                    Re: Getting Started with C; Terminal does not compile my file Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-23 02:52 -0700
                      Re: Getting Started with C; Terminal does not compile my file David Brown <david.brown@hesbynett.no> - 2015-04-23 13:52 +0200
                        Re: Getting Started with C; Terminal does not compile my file Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-23 05:21 -0700
                          Re: Getting Started with C; Terminal does not compile my file gazelle@shell.xmission.com (Kenny McCormack) - 2015-04-23 12:34 +0000
                          Re: Getting Started with C; Terminal does not compile my file Melzzzzz <mel@zzzzz.com> - 2015-04-23 15:15 +0200
                            Re: Getting Started with C; Terminal does not compile my file gazelle@shell.xmission.com (Kenny McCormack) - 2015-04-23 13:24 +0000
                              Re: Getting Started with C; Terminal does not compile my file Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-23 06:42 -0700
                          Re: Getting Started with C; Terminal does not compile my file Ben Bacarisse <ben.lists@bsb.me.uk> - 2015-04-23 14:58 +0100
                          Re: Getting Started with C; Terminal does not compile my file David Brown <david.brown@hesbynett.no> - 2015-04-23 16:07 +0200
                            Re: Getting Started with C; Terminal does not compile my file Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-23 07:41 -0700
                              Re: Getting Started with C; Terminal does not compile my file David Brown <david.brown@hesbynett.no> - 2015-04-23 17:28 +0200
                        Re: Getting Started with C; Terminal does not compile my file gazelle@shell.xmission.com (Kenny McCormack) - 2015-04-23 12:36 +0000
                          Re: Getting Started with C; Terminal does not compile my file David Brown <david.brown@hesbynett.no> - 2015-04-23 15:50 +0200
                      Re: Getting Started with C; Terminal does not compile my file raltbos@xs4all.nl (Richard Bos) - 2015-04-25 10:23 +0000
    Re: Getting Started with C; Terminal does not compile my file Greg Martin <greg.at.softsprocket@dot.com> - 2015-04-21 13:37 +0000
    Re: Getting Started with C; Terminal does not compile my file Xcott Craver <xcottcraver@gmail.com> - 2015-04-21 06:53 -0700
    Re: Getting Started with C; Terminal does not compile my file Alla _ <modelling.data@gmail.com> - 2015-04-21 07:43 -0700
    Re: Getting Started with C; Terminal does not compile my file G G <gdotone@gmail.com> - 2015-04-26 09:15 -0700
      Re: Getting Started with C; Terminal does not compile my file Keith Thompson <kst-u@mib.org> - 2015-04-26 12:43 -0700
        Re: Getting Started with C; Terminal does not compile my file G G <gdotone@gmail.com> - 2015-04-26 14:53 -0700

Page 1 of 3  [1] 2 3  Next page →


#60611 — Getting Started with C; Terminal does not compile my file

FromAlla _ <modelling.data@gmail.com>
Date2015-04-21 00:31 -0700
SubjectGetting Started with C; Terminal does not compile my file
Message-ID<5d933960-8ebd-47a2-8bd4-cc9de8f77031@googlegroups.com>
Hello!

I would be grateful for the help. 

I am trying to perform first task from the textbook (simplest task on creating first short program in C; following the example from the book, which is the same at Howstuffworks.com):

Xcode works (at least types and highlights words in program), Terminal opens and partially works, but does not execute compile command. 

I have tried different options. Please, take a look at the steps; what is my mistake?

Mac OS X 10.7.5

Xcode command:

#include <studio.h>



int main (void)

{

    printf ("Programming is fun.\n");

    printf ("And programming in C is even more fun.\n");

    

    return 0;

}

Then Terminal:

128-68-198-68:GetStarted Alla$ open CS50PSET1.c
128-68-198-68:GetStarted Alla$ gcc CS50PSET1.c
-bash: gcc: command not found
128-68-198-68:GetStarted Alla$ cc CS50PSET1.c
-bash: cc: command not found
128-68-198-68:GetStarted Alla$ gcc CS50PSET1.c -o CS50PSET1
-bash: gcc: command not found
128-68-198-68:GetStarted Alla$ gcc -o CS50PSET1.c
-bash: gcc: command not found
128-68-198-68:GetStarted Alla$ gcc /Users/Alla/GetStarted/CS50PSET1.c 
-bash: gcc: command not found
128-68-198-68:GetStarted Alla$ 

Thank you! 

[toc] | [next] | [standalone]


#60621

FromNoob <root@127.0.0.1>
Date2015-04-21 11:38 +0200
Message-ID<mh55pa$2ui$1@dont-email.me>
In reply to#60611
On 21/04/2015 09:31, Alla _ wrote:

> I am trying to perform first task from the textbook (simplest task on
> creating first short program in C; following the example from the
> book, which is the same at Howstuffworks.com):
>
> Xcode works (at least types and highlights words in program),
> Terminal opens and partially works, but does not execute compile
> command.
>
> I have tried different options. Please, take a look at the steps;
> what is my mistake?
>
> Mac OS X 10.7.5
> Xcode command:
>
> #include <studio.h>

That's cute. It's "stdio.h", as in "Standard Input/Ouput".

Seems like you need an Xcode tutorial. Perhaps this one:
http://masters-of-the-void.com/

Regards.

[toc] | [prev] | [next] | [standalone]


#60623

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2015-04-21 11:12 +0100
Message-ID<87fv7t6b9p.fsf@bsb.me.uk>
In reply to#60611
Alla _ <modelling.data@gmail.com> writes:
<snip>
> Xcode works (at least types and highlights words in program), Terminal
> opens and partially works, but does not execute compile command.
>
> I have tried different options. Please, take a look at the steps; what
> is my mistake?
>
> Mac OS X 10.7.5
<snip>
> 128-68-198-68:GetStarted Alla$ gcc CS50PSET1.c
> -bash: gcc: command not found

A web search shows that Xcode (at least in some versions) has an option
to install the command line tools.  To quote one site:

  "Xcode menu > Preferences > Downloads > choose "Command line tools" >
  Click "Install" button:"

You should try to find somewhere where MacOS experts hang out.  I know
next to nothing about Macs or Xcode, but there must be somewhere where
you can find people to help with this sort of thing.  This is a group
about the C language itself, so it is rather hit-and-miss if anyone here
can help with this sort of question.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#60633

FromMalcolm McLean <malcolm.mclean5@btinternet.com>
Date2015-04-21 06:21 -0700
Message-ID<96890356-e306-4fa9-bd0c-6d0934205cc7@googlegroups.com>
In reply to#60611
On Tuesday, April 21, 2015 at 8:31:45 AM UTC+1, Alla _ wrote:
> Hello!
> 
>
> I have tried different options. Please, take a look at the steps; what is my mistake?
> 
> Mac OS X 10.7.5
> 
> Xcode command:
> 
> #include <studio.h>
> 
> 
> 
> int main (void)
> 
> {
> 
>     printf ("Programming is fun.\n");
> 
>     printf ("And programming in C is even more fun.\n");
> 
>     
> 
>     return 0;
> 
> }
> 
> Then Terminal:
> 
> 128-68-198-68:GetStarted Alla$ open CS50PSET1.c
> 128-68-198-68:GetStarted Alla$ gcc CS50PSET1.c
> -bash: gcc: command not found
>
You don't have gcc installed.
The easiest way to get programs on the Mac is via home-brew.
Type "brew" and see if you have it.
If not, do a web search on "Homebrew, apple mac" and follow the
instructions (obviously it can't install itself).

Then you type 
brew install gcc

If it throws instructions at you, follow them.

The Xcode compiler is clang. You can also try running that from
the command line. But it's probably easier to use gcc - clang is
basically an objective C compiler so a bit strange.

>

[toc] | [prev] | [next] | [standalone]


#60634

FromGreg Martin <greg.at.softsprocket@dot.com>
Date2015-04-21 13:35 +0000
Message-ID<rmsZw.340671$jx4.288429@fx27.iad>
In reply to#60633
On 2015-04-21, Malcolm McLean <malcolm.mclean5@btinternet.com> wrote:
> On Tuesday, April 21, 2015 at 8:31:45 AM UTC+1, Alla _ wrote:
>> Hello!
>> 
>>
>> I have tried different options. Please, take a look at the steps; what is my mistake?
>> 
>> Mac OS X 10.7.5
>> 
>> Xcode command:
>> 
>> #include <studio.h>
>> 
>> 
>> 
>> int main (void)
>> 
>> {
>> 
>>     printf ("Programming is fun.\n");
>> 
>>     printf ("And programming in C is even more fun.\n");
>> 
>>     
>> 
>>     return 0;
>> 
>> }
>> 
>> Then Terminal:
>> 
>> 128-68-198-68:GetStarted Alla$ open CS50PSET1.c
>> 128-68-198-68:GetStarted Alla$ gcc CS50PSET1.c
>> -bash: gcc: command not found
>>
> You don't have gcc installed.
> The easiest way to get programs on the Mac is via home-brew.
> Type "brew" and see if you have it.
> If not, do a web search on "Homebrew, apple mac" and follow the
> instructions (obviously it can't install itself).
>
> Then you type 
> brew install gcc
>
> If it throws instructions at you, follow them.
>
> The Xcode compiler is clang. You can also try running that from
> the command line. But it's probably easier to use gcc - clang is
> basically an objective C compiler so a bit strange.
>
>>

This has not been my experiemce. Clang is pretty much a drop in replacement
for gcc on Linux at least, except it sometimes gives clearer diagnostics
and can be faster.

-- 
http://www.softsprocket.com

[toc] | [prev] | [next] | [standalone]


#60636

Fromgazelle@shell.xmission.com (Kenny McCormack)
Date2015-04-21 13:38 +0000
Message-ID<mh5jt2$46v$2@news.xmission.com>
In reply to#60633
In article <96890356-e306-4fa9-bd0c-6d0934205cc7@googlegroups.com>,
Malcolm McLean  <malcolm.mclean5@btinternet.com> wrote:
...
>The Xcode compiler is clang. You can also try running that from
>the command line.

If you've installed it correctly, it will also have an executable called
"gcc" - that is a front-end to clang.  I always invoke it as gcc on my Mac.

>But it's probably easier to use gcc -

It is difficult to impossible to get actual gcc on the Mac nowadays.

>clang is basically an objective C compiler so a bit strange.

I'm not so sure about that...

-- 
There are two kinds of Republicans: Billionaires and suckers.
Republicans: Please check your bank account and decide which one is you.

[toc] | [prev] | [next] | [standalone]


#60637

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2015-04-21 14:44 +0100
Message-ID<87pp6x4mvk.fsf@bsb.me.uk>
In reply to#60633
Malcolm McLean <malcolm.mclean5@btinternet.com> writes:
<snip>
> The Xcode compiler is clang. You can also try running that from
> the command line.

If you install the command-line tools you get a gcc command.  It's
basically a clang compiler but there is no need to install another huge
compilation system.  I should add "so I hear" because this is all second
hand.

> But it's probably easier to use gcc - clang is
> basically an objective C compiler so a bit strange.

clang makes a great C compiler.  gcc is also makes a fine objective-c
compiler.  Neither fact makes either of them "a bit strange".  There
will likely to be more strangeness if the OP ends up with two compilers
-- one called from Xcode and the other on the command line.  I'd advise
against that set up.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#60651

FromKeith Thompson <kst-u@mib.org>
Date2015-04-21 08:45 -0700
Message-ID<87k2x5mqnr.fsf@kst-u.example.com>
In reply to#60633
Malcolm McLean <malcolm.mclean5@btinternet.com> writes:
[...]
> You don't have gcc installed.
> The easiest way to get programs on the Mac is via home-brew.
> Type "brew" and see if you have it.
> If not, do a web search on "Homebrew, apple mac" and follow the
> instructions (obviously it can't install itself).
>
> Then you type 
> brew install gcc
>
> If it throws instructions at you, follow them.
>
> The Xcode compiler is clang. You can also try running that from
> the command line. But it's probably easier to use gcc - clang is
> basically an objective C compiler so a bit strange.

Your claim that "clang is basically an objective C compiler" is,
to the best of my knowledge, completely incorrect, and I wonder
where you got that idea.  Clang includes C, C++, Objective-C,
and Objective-C++ front ends -- as does gcc.

As I recall, the default installation on Mac OSX uses the name "gcc"
to invoke the clang compiler (probably to avoid breaking Makefiles
that assume the C compiler is called "gcc").  If you have a compiler
installed, typing "gcc --version" will tell you which compiler it is.

If I recall correctly, clang is the default C and C++ compiler
for MacOS.  It can also be installed on Linux systems, though such
installations typically do not use "gcc" as the command name to
invoke clang.  (I have both gcc and clang installed on my system).

My recommendation to the original poster is to set up the
command-line tools in the usual way for Mac OSX.  I *think* that
the usual way is to install clang.  You can certainly install gcc if
you prefer, but that's going to be more complicated and I wouldn't
recommend it for the original poster.  There are valid reasons to
want to use gcc on OSX, but they're unlikely to apply here.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#60726

FromMalcolm McLean <malcolm.mclean5@btinternet.com>
Date2015-04-22 05:35 -0700
Message-ID<1f206b33-3556-4d74-871c-ee727e0f276d@googlegroups.com>
In reply to#60651
On Tuesday, April 21, 2015 at 4:45:25 PM UTC+1, Keith Thompson wrote:
> Malcolm McLean <malcolm.mclean5@btinternet.com> writes:
>
> Your claim that "clang is basically an objective C compiler" is,
> to the best of my knowledge, completely incorrect, and I wonder
> where you got that idea.  Clang includes C, C++, Objective-C,
> and Objective-C++ front ends -- as does gcc.
> 
I use it from Xcode.
X code allows you to write C or C++ code, but it's set up for Objective C programmers.
There are all sorts of ways of building GUIs by clicking with the mouse and getting
it to insert fragments of Objective C.
It also falls over on our C++ base, which, to be fair to it, is written in a  very avant
guarde C++ style with lots of templates, lamas, boost, and all the goodies.

An Apple application is a "package". Whilst it contains executable files 
machine code, it's also got folders for resources, and the dylibs. The dylibs
have a path signature of some sort that has to be right before they'll work on
another person's machine. I forget all the details, it's very fiddly. But it's
all transparent to Objective C, you just click on an image and it will write
the Objective C to put your image in a little window on screen, and transfer it
to the resources folder in your package. C doesn't really have a concept of a 
"resource".

So my conclusion was that it was basically an Objective C compiler.
 

[toc] | [prev] | [next] | [standalone]


#60757

FromKeith Thompson <kst-u@mib.org>
Date2015-04-22 10:20 -0700
Message-ID<878udkkrku.fsf@kst-u.example.com>
In reply to#60726
ram@zedat.fu-berlin.de (Stefan Ram) writes:
> Malcolm McLean <malcolm.mclean5@btinternet.com> writes:
>>                                         C doesn't really have a concept of a 
>>"resource".
>
> #include <threads.h>
> void cnd_destroy(cnd_t *cond);
> Description
> The cnd_destroy function releases all resources used by the condition variable
> pointed to by cond.

Sure, but that's not the kind of "resource" that Xcode and/or
Objective-C apparently deals with.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#60759

FromKeith Thompson <kst-u@mib.org>
Date2015-04-22 10:17 -0700
Message-ID<87d22wkrpc.fsf@kst-u.example.com>
In reply to#60726
Malcolm McLean <malcolm.mclean5@btinternet.com> writes:
> On Tuesday, April 21, 2015 at 4:45:25 PM UTC+1, Keith Thompson wrote:
>> Malcolm McLean <malcolm.mclean5@btinternet.com> writes:
>> Your claim that "clang is basically an objective C compiler" is,
>> to the best of my knowledge, completely incorrect, and I wonder
>> where you got that idea.  Clang includes C, C++, Objective-C,
>> and Objective-C++ front ends -- as does gcc.
>> 
> I use it from Xcode.
> X code allows you to write C or C++ code, but it's set up for Objective C programmers.
> There are all sorts of ways of building GUIs by clicking with the mouse and getting
> it to insert fragments of Objective C.
> It also falls over on our C++ base, which, to be fair to it, is written in a  very avant
> guarde C++ style with lots of templates, lamas, boost, and all the goodies.
>
> An Apple application is a "package". Whilst it contains executable files 
> machine code, it's also got folders for resources, and the dylibs. The dylibs
> have a path signature of some sort that has to be right before they'll work on
> another person's machine. I forget all the details, it's very fiddly. But it's
> all transparent to Objective C, you just click on an image and it will write
> the Objective C to put your image in a little window on screen, and transfer it
> to the resources folder in your package. C doesn't really have a concept of a 
> "resource".
>
> So my conclusion was that it was basically an Objective C compiler.

Are you explaining how you made that mistake, or are you continuing to
defend it?

Again, I believe your conclusion is completely incorrect.  What you
describe is consistent with Xcode (an IDE) being primarily oriented
to Objective-C development.  It happens to use clang, which
supports, C, C++, Objective-C, and Objective-C++, as its compiler.
The compiler itself does not, as far as I know, have any particular
preference for Objective-C.

The OP was asking about compiling from the command line.  Your
concerns about Xcode and clang are irrelevant to what the OP is
trying to do.  Installing gcc rather than clang would not be helpful.
Of course there are valid reasons to want to use gcc rather than
clang, but an emphasis on Objective-C is not one of them, and for
the OP's purposes, following the OSX default is likely to be easier.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#60787

FromMalcolm McLean <malcolm.mclean5@btinternet.com>
Date2015-04-22 12:56 -0700
Message-ID<96804a4a-53af-4a96-ac05-53b5ffd51a34@googlegroups.com>
In reply to#60759
On Wednesday, April 22, 2015 at 6:18:05 PM UTC+1, Keith Thompson wrote:
> Malcolm McLean <malcolm.mclean5@btinternet.com> writes:
> 
> Again, I believe your conclusion is completely incorrect.  What you
> describe is consistent with Xcode (an IDE) being primarily oriented
> to Objective-C development.  It happens to use clang, which
> supports, C, C++, Objective-C, and Objective-C++, as its compiler.
> The compiler itself does not, as far as I know, have any particular
> preference for Objective-C.
>
Xcode regularly falls over on our codebase of admittedly rather 
advanced C++. From the error messages, it appears that the error
is in the compiler rather than the IDE, but it's impossible to be sure.

Restarting it usually fixes the problem.

So my conclusion is that it's because C++ was an afterthought, and
basically it's intended to compile Objective C. I might be wrong.
>
> The OP was asking about compiling from the command line.  Your
> concerns about Xcode and clang are irrelevant to what the OP is
> trying to do.  Installing gcc rather than clang would not be helpful.
> Of course there are valid reasons to want to use gcc rather than
> clang, but an emphasis on Objective-C is not one of them, and for
> the OP's purposes, following the OSX default is likely to be easier.
> 
Apparently it's just the same compiler, which I wasn't aware of.
It's just got slightly different options parsing.

But if you've ever seen the Xcode options list, it's a major
headache.

[toc] | [prev] | [next] | [standalone]


#60792

FromKeith Thompson <kst-u@mib.org>
Date2015-04-22 13:28 -0700
Message-ID<87d22vkiuz.fsf@kst-u.example.com>
In reply to#60787
Malcolm McLean <malcolm.mclean5@btinternet.com> writes:
> On Wednesday, April 22, 2015 at 6:18:05 PM UTC+1, Keith Thompson wrote:
>> Malcolm McLean <malcolm.mclean5@btinternet.com> writes:
>> Again, I believe your conclusion is completely incorrect.  What you
>> describe is consistent with Xcode (an IDE) being primarily oriented
>> to Objective-C development.  It happens to use clang, which
>> supports, C, C++, Objective-C, and Objective-C++, as its compiler.
>> The compiler itself does not, as far as I know, have any particular
>> preference for Objective-C.
>>
> Xcode regularly falls over on our codebase of admittedly rather 
> advanced C++. From the error messages, it appears that the error
> is in the compiler rather than the IDE, but it's impossible to be sure.
>
> Restarting it usually fixes the problem.

It's surprising that a C++ compiler producing an error message for
"rather advanced C++" is a problem that would be corrected by restarting
the IDE.  But since that's either an IDE issue, a compiler issue, or a
C++ issue, I won't ask for details.

> So my conclusion is that it's because C++ was an afterthought, and
> basically it's intended to compile Objective C. I might be wrong.

Yes, I believe you are.  clang was designed as a replacement for gcc.

Perhaps you might consider doing a quick Google search before repeating
your claim -- though I'm glad to see you admit that you might be wrong.

>> The OP was asking about compiling from the command line.  Your
>> concerns about Xcode and clang are irrelevant to what the OP is
>> trying to do.  Installing gcc rather than clang would not be helpful.
>> Of course there are valid reasons to want to use gcc rather than
>> clang, but an emphasis on Objective-C is not one of them, and for
>> the OP's purposes, following the OSX default is likely to be easier.
>> 
> Apparently it's just the same compiler, which I wasn't aware of.
> It's just got slightly different options parsing.

Hmm?  What is "just the same compiler" as what?

gcc and clang are two different compilers.  On OSX, clang is commonly
installed using the name "gcc" as the command to invoke it, but
"gcc --version" will tell you which one you're using.

[...]

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#60797

FromMalcolm McLean <malcolm.mclean5@btinternet.com>
Date2015-04-22 14:23 -0700
Message-ID<f7cc8b13-4498-48ee-8775-f342cfb0d78f@googlegroups.com>
In reply to#60792
On Wednesday, April 22, 2015 at 9:29:00 PM UTC+1, Keith Thompson wrote:
> Malcolm McLean <malcolm.mclean5@btinternet.com> writes:
>
> > Xcode regularly falls over on our codebase of admittedly rather 
> > advanced C++. From the error messages, it appears that the error
> > is in the compiler rather than the IDE, but it's impossible to be sure.
> >
> > Restarting it usually fixes the problem.
> 
> It's surprising that a C++ compiler producing an error message for
> "rather advanced C++" is a problem that would be corrected by restarting
> the IDE.  But since that's either an IDE issue, a compiler issue, or a
> C++ issue, I won't ask for details.
> 
It crashes out on our medium-size codebase. So you shut down the IDE,#and have another go, and usually it works. This happens when you touch 
something that needs a non-trivial number of file recompiles.
But I think it's a bug in clang rather than the IDE, because it
reports at fatal error in a given source file and line number.
When you look at it there's nothing wrong with the code.

So it's what you'd expect if someone had written an Objective C
compiler and then made it compile C++ as well. Just as I can hold
a conversation in French at a pinch, but with lots of mistakes -
it's a second language from me. 

If the command "gcc" evokes clang, which seems to be the case, then
we've got a philosophical question here. Are gcc and clang the
same compiler?

[toc] | [prev] | [next] | [standalone]


#60801

FromBartc <bc@freeuk.com>
Date2015-04-22 22:39 +0100
Message-ID<mh94bt$jn$1@dont-email.me>
In reply to#60797
On 22/04/2015 22:23, Malcolm McLean wrote:
> On Wednesday, April 22, 2015 at 9:29:00 PM UTC+1, Keith Thompson wrote:

> It crashes out on our medium-size codebase. So you shut down the IDE,#and have another go, and usually it works. This happens when you touch
> something that needs a non-trivial number of file recompiles.
> But I think it's a bug in clang rather than the IDE, because it
> reports at fatal error in a given source file and line number.
> When you look at it there's nothing wrong with the code.

How about running the compiler outside the IDE?

> So it's what you'd expect if someone had written an Objective C
> compiler and then made it compile C++ as well. Just as I can hold
> a conversation in French at a pinch, but with lots of mistakes -
> it's a second language from me.
>
> If the command "gcc" evokes clang, which seems to be the case, then
> we've got a philosophical question here. Are gcc and clang the
> same compiler?

They're separate projects, but on that platform it sounds like the true 
gcc isn't installed or doesn't work, so it will invoke clang.

I think clang is designed to be a replacement (or alternative) to gcc, 
and appears to support the same extensions and the same options as gcc. 
(But, for x86, it doesn't generate quite as good code as gcc, unless 
that's changed recently.)

-- 
Bartc

[toc] | [prev] | [next] | [standalone]


#60803

Fromgazelle@shell.xmission.com (Kenny McCormack)
Date2015-04-22 21:45 +0000
Message-ID<mh94qb$8sg$1@news.xmission.com>
In reply to#60801
In article <mh94bt$jn$1@dont-email.me>, Bartc  <bc@freeuk.com> wrote:
...
>They're separate projects, but on that platform it sounds like the true 
>gcc isn't installed or doesn't work, so it will invoke clang.

Apple has its own reasons for preferring clang to gcc.  A little bit of web
surfing will bring you lots of information as to those reasons.  This is
why clang is the only compiler that, to the best of my knowledge, is easily
available for download and installation on the Mac.

I am told that it is possible to compile (and run!) GCC on the Mac, using
clang to do the compilation; that it is not particularly hard, just time
consuming.  I want to do it myself at some point (when I get a round tuit).
There is one particular feature of GCC that clang does not have, that I
need for some of my own software.  I will leave it to you to figure out
what that feature is...

>I think clang is designed to be a replacement (or alternative) to gcc, 
>and appears to support the same extensions and the same options as gcc. 
>(But, for x86, it doesn't generate quite as good code as gcc, unless 
>that's changed recently.)

Interesting.  I wonder what Apple and the clang developers would say about
that.

-- 
Here's a simple test for Fox viewers:

1) Sit back, close your eyes, and think (Yes, I know that's hard for you).
2) Think about and imagine all of your ridiculous fantasies about Barack Obama.
3) Now, imagine that he is white.  Cogitate on how absurd your fantasies
seem now.

See?  That wasn't hard, was it?

[toc] | [prev] | [next] | [standalone]


#60834

FromBartc <bc@freeuk.com>
Date2015-04-23 01:28 +0100
Message-ID<mh9ea4$4l9$1@dont-email.me>
In reply to#60803
On 22/04/2015 22:45, Kenny McCormack wrote:
> In article <mh94bt$jn$1@dont-email.me>, Bartc  <bc@freeuk.com> wrote:

>> I think clang is designed to be a replacement (or alternative) to gcc,
>> and appears to support the same extensions and the same options as gcc.
>> (But, for x86, it doesn't generate quite as good code as gcc, unless
>> that's changed recently.)
>
> Interesting.  I wonder what Apple and the clang developers would say about
> that.

I've quickly tested it again, and clang's code was 20-30% slower than 
gcc. That was clang 3.4, but I upgraded to 3.6 and it was the same.

(This was tested with one specific project: my C interpreter code. But I 
think I've seen a difference with other programs too. Both compilers 
used -O3 optimisation. Personally I quite like clang but only because I 
can almost match its code generation with my own compiler.)

But I suppose it's also possible that the non-MacOS versions of clang 
have been deliberately crippled...

-- 
Bartc

[toc] | [prev] | [next] | [standalone]


#60842

FromDavid Brown <david.brown@hesbynett.no>
Date2015-04-23 09:30 +0200
Message-ID<mha709$3ua$1@dont-email.me>
In reply to#60801
On 22/04/15 23:39, Bartc wrote:
> On 22/04/2015 22:23, Malcolm McLean wrote:
>> On Wednesday, April 22, 2015 at 9:29:00 PM UTC+1, Keith Thompson wrote:
> 
>> It crashes out on our medium-size codebase. So you shut down the
>> IDE,#and have another go, and usually it works. This happens when you
>> touch
>> something that needs a non-trivial number of file recompiles.
>> But I think it's a bug in clang rather than the IDE, because it
>> reports at fatal error in a given source file and line number.
>> When you look at it there's nothing wrong with the code.
> 
> How about running the compiler outside the IDE?
> 
>> So it's what you'd expect if someone had written an Objective C
>> compiler and then made it compile C++ as well. Just as I can hold
>> a conversation in French at a pinch, but with lots of mistakes -
>> it's a second language from me.
>>
>> If the command "gcc" evokes clang, which seems to be the case, then
>> we've got a philosophical question here. Are gcc and clang the
>> same compiler?
> 
> They're separate projects, but on that platform it sounds like the true
> gcc isn't installed or doesn't work, so it will invoke clang.
> 
> I think clang is designed to be a replacement (or alternative) to gcc,
> and appears to support the same extensions and the same options as gcc.
> (But, for x86, it doesn't generate quite as good code as gcc, unless
> that's changed recently.)
> 

clang/llvm is an alternative to gcc, with a similar function but a very
different design strategy.  Both support a range of languages at the
front-end (gcc covers C, C++, Objective-C, Objective-C++, java, go,
fortran, Ada, plus a variety of "unofficial" front-ends like Pascal.
llvm also supports a variety, with "clang" being the front-end for C,
C++ and Objective-C).  Both have a "middle-end" handling optimisations
on abstract code trees.  Both have a variety of back-ends for different
targets (gcc supports far more than llvm, but llvm is considered easier
for making new targets).

For compatibility, clang supports most of gcc's extensions (as do other
serious compilers, such as Intel's) - but clang also has several of its
own.  Of particular note is its module system - I hope one day that will
make it into gcc and the C standards.

The two compilers have benefited enormously from each other for
competitive inspiration and a certain degree of direct collaboration -
there have been several projects for new features that are developed to
work with both toolchains.

As a general guideline, gcc supports more targets and more target
details (like for variants of x86), and generates smaller and faster
object code.  llvm runs significantly faster, and has (at least until
recent gcc's, which have caught up somewhat) produced better diagnostics.

[toc] | [prev] | [next] | [standalone]


#60849

FromMelzzzzz <mel@zzzzz.com>
Date2015-04-23 10:38 +0200
Message-ID<20150423103800.55ba3429@maxa-pc>
In reply to#60842
On Thu, 23 Apr 2015 09:30:12 +0200
David Brown <david.brown@hesbynett.no> wrote:

> 
> As a general guideline, gcc supports more targets and more target
> details (like for variants of x86), and generates smaller and faster
> object code.  llvm runs significantly faster, and has (at least until
> recent gcc's, which have caught up somewhat) produced better
> diagnostics.

I don't think that gcc generates smaller code... faster from case to
case, yes, but gcc supports openmp.

[toc] | [prev] | [next] | [standalone]


#60874

FromDavid Brown <david.brown@hesbynett.no>
Date2015-04-23 13:44 +0200
Message-ID<mhalsa$nek$2@dont-email.me>
In reply to#60849
On 23/04/15 10:38, Melzzzzz wrote:
> On Thu, 23 Apr 2015 09:30:12 +0200
> David Brown <david.brown@hesbynett.no> wrote:
> 
>>
>> As a general guideline, gcc supports more targets and more target
>> details (like for variants of x86), and generates smaller and faster
>> object code.  llvm runs significantly faster, and has (at least until
>> recent gcc's, which have caught up somewhat) produced better
>> diagnostics.
> 
> I don't think that gcc generates smaller code... faster from case to
> case, yes, but gcc supports openmp.
> 

I haven't done any comparisons myself, so my comments here are second
(or third) hand.  The general opinion is that gcc can generate faster
code than llvm at the moment, and has more powerful optimisations
(features such as openmp are in addition to this).  Of course your
mileage may vary according to application.

[toc] | [prev] | [next] | [standalone]


Page 1 of 3  [1] 2 3  Next page →

Back to top | Article view | comp.lang.c


csiph-web