public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* is the c code in gcc comiled sequentially???
@ 2006-11-15  6:13 enggakshat
  2006-11-15 12:20 ` John Love-Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: enggakshat @ 2006-11-15  6:13 UTC (permalink / raw)
  To: gcc-help


i m a newbie to gcc and i have been making a project lately on netwoking.
yesterday i encountered a starnge situation wherein it so happened that d
program that i made was not sequentially executed.any ideas so as to why?plz
ask for the code details if required
-- 
View this message in context: http://www.nabble.com/is-the-c-code-in-gcc-comiled-sequentially----tf2634251.html#a7352560
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: is the c code in gcc comiled sequentially???
  2006-11-15  6:13 is the c code in gcc comiled sequentially??? enggakshat
@ 2006-11-15 12:20 ` John Love-Jensen
  2006-11-15 15:07   ` enggakshat
  0 siblings, 1 reply; 9+ messages in thread
From: John Love-Jensen @ 2006-11-15 12:20 UTC (permalink / raw)
  To: enggakshat, MSX to GCC

Hi enggakshat,

What version of GCC are you using?

What programming language from GCC are you using?  Ah, by your title, it
appears you are using C -- not C++, FORTRAN, Ada, Java 1.4, D Programming
Language, or some other language supported by GCC.

What hardware platform are you using?

What operating system are you using?

What command line arguments for GCC's gcc tool chain driver are you using?

Can you provide some COMPILABLE minimal example code that reproduces the
problem?

Thanks,
--Eljay

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: is the c code in gcc comiled sequentially???
  2006-11-15 12:20 ` John Love-Jensen
@ 2006-11-15 15:07   ` enggakshat
  2006-11-15 15:35     ` Ian Lance Taylor
  2006-11-15 15:38     ` John Love-Jensen
  0 siblings, 2 replies; 9+ messages in thread
From: enggakshat @ 2006-11-15 15:07 UTC (permalink / raw)
  To: gcc-help



John Love-Jensen wrote:
> 
> Hi enggakshat,
> 
> What version of GCC are you using?
> 
> What programming language from GCC are you using?  Ah, by your title, it
> appears you are using C -- not C++, FORTRAN, Ada, Java 1.4, D Programming
> Language, or some other language supported by GCC.
> 
> What hardware platform are you using?
> 
> What operating system are you using?
> 
> What command line arguments for GCC's gcc tool chain driver are you using?
> 
> Can you provide some COMPILABLE minimal example code that reproduces the
> problem?
> 
> Thanks,
> --Eljay
> 
> 
> 
hi john,

following are the specifications u asked for.
-gcc version 4.0.3 (Ubuntu 4.0.3-1ubuntu5)

-i m using c++

-Ubuntu 6.06 LTS

-i m using a dell inspiron 6000 
->1.6 ghz intel centrino(MT)
->1 gb RAM

-i really dont have a clue to what tool chain driver means.sorry for that.


-eg:
for the following simple code i thought its obvious that 'hello' is printed
but that doesnt happen.
as far as i knew the code is executed sequentially. 

#include<iostream>

using namespace std;

int main()

{
 int i=0;
 cout<<"hello";
 while(1)
 {
  i++;
 }
}

regards,
Akshat
-- 
View this message in context: http://www.nabble.com/is-the-c-code-in-gcc-compiled-sequentially----tf2634251.html#a7359255
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: is the c code in gcc comiled sequentially???
  2006-11-15 15:07   ` enggakshat
@ 2006-11-15 15:35     ` Ian Lance Taylor
  2006-11-15 17:57       ` enggakshat
  2006-11-15 15:38     ` John Love-Jensen
  1 sibling, 1 reply; 9+ messages in thread
From: Ian Lance Taylor @ 2006-11-15 15:35 UTC (permalink / raw)
  To: enggakshat; +Cc: gcc-help

enggakshat <enggakshat@yahoo.com> writes:

> for the following simple code i thought its obvious that 'hello' is printed
> but that doesnt happen.
> as far as i knew the code is executed sequentially. 
> 
> #include<iostream>
> 
> using namespace std;
> 
> int main()
> 
> {
>  int i=0;
>  cout<<"hello";
>  while(1)
>  {
>   i++;
>  }
> }

This is most likely a buffering issue.  std::cout is normally line
buffered by default, which means that it is only flushed when you
output a newline character.  Try this:
    cout << unitbuf << "hello";

Ian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: is the c code in gcc comiled sequentially???
  2006-11-15 15:07   ` enggakshat
  2006-11-15 15:35     ` Ian Lance Taylor
@ 2006-11-15 15:38     ` John Love-Jensen
  2006-11-15 17:55       ` enggakshat
  1 sibling, 1 reply; 9+ messages in thread
From: John Love-Jensen @ 2006-11-15 15:38 UTC (permalink / raw)
  To: enggakshat, MSX to GCC

Hi Akshat,

> -i really dont have a clue to what tool chain driver means.sorry for that.

A "tool chain driver" is a program that executes other programs, in the
proper order, to achieve a particular goal.

For example, the gcc tool chain driver runs the preprocessor, then takes the
output from the preprocessor and runs that output through the compiler, then
takes that output from the compiler and runs it through the assembler, then
takes that output from the assembler and runs it through the linker, to
produce the executable.

> for the following simple code i thought its obvious that 'hello' is printed
> but that doesnt happen.
> as far as i knew the code is executed sequentially.

You have not flushed your buffer yet, so the "Hello" is languishing in the
buffer.

Add a ...
cout.flush();
... statement to flush the buffer, before entering the loop.

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: is the c code in gcc comiled sequentially???
  2006-11-15 15:38     ` John Love-Jensen
@ 2006-11-15 17:55       ` enggakshat
  0 siblings, 0 replies; 9+ messages in thread
From: enggakshat @ 2006-11-15 17:55 UTC (permalink / raw)
  To: gcc-help




John Love-Jensen wrote:
> 
> Hi Akshat,
> 
>> -i really dont have a clue to what tool chain driver means.sorry for
>> that.
> 
> A "tool chain driver" is a program that executes other programs, in the
> proper order, to achieve a particular goal.
> 
> For example, the gcc tool chain driver runs the preprocessor, then takes
> the
> output from the preprocessor and runs that output through the compiler,
> then
> takes that output from the compiler and runs it through the assembler,
> then
> takes that output from the assembler and runs it through the linker, to
> produce the executable.
> 
>> for the following simple code i thought its obvious that 'hello' is
>> printed
>> but that doesnt happen.
>> as far as i knew the code is executed sequentially.
> 
> You have not flushed your buffer yet, so the "Hello" is languishing in the
> buffer.
> 
> Add a ...
> cout.flush();
> ... statement to flush the buffer, before entering the loop.
> 
> HTH,
> --Eljay
> 
> 
> 
thanks a lot dude.

regards 
Akshat
-- 
View this message in context: http://www.nabble.com/is-the-c-code-in-gcc-compiled-sequentially----tf2634251.html#a7362822
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: is the c code in gcc comiled sequentially???
  2006-11-15 15:35     ` Ian Lance Taylor
@ 2006-11-15 17:57       ` enggakshat
  2006-11-15 19:18         ` Young, Michael
  0 siblings, 1 reply; 9+ messages in thread
From: enggakshat @ 2006-11-15 17:57 UTC (permalink / raw)
  To: gcc-help




Ian Lance Taylor-3 wrote:
> 
> enggakshat <enggakshat@yahoo.com> writes:
> 
>> for the following simple code i thought its obvious that 'hello' is
>> printed
>> but that doesnt happen.
>> as far as i knew the code is executed sequentially. 
>> 
>> #include<iostream>
>> 
>> using namespace std;
>> 
>> int main()
>> 
>> {
>>  int i=0;
>>  cout<<"hello";
>>  while(1)
>>  {
>>   i++;
>>  }
>> }
> 
> This is most likely a buffering issue.  std::cout is normally line
> buffered by default, which means that it is only flushed when you
> output a newline character.  Try this:
>     cout << unitbuf << "hello";
> 
> Ian
> 
> 
thanks a lot .it worked.is there any suggested reading from where i can get
more info on buffers in c++

regards
Akshat
-- 
View this message in context: http://www.nabble.com/is-the-c-code-in-gcc-compiled-sequentially----tf2634251.html#a7362882
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: is the c code in gcc comiled sequentially???
  2006-11-15 17:57       ` enggakshat
@ 2006-11-15 19:18         ` Young, Michael
  0 siblings, 0 replies; 9+ messages in thread
From: Young, Michael @ 2006-11-15 19:18 UTC (permalink / raw)
  To: enggakshat, gcc-help

I recommend Langer and Kreft's book, "Standard C++ IOStreams and Locales:
 Advanced Programmer's Guide and Reference" for a full explanation of iostreams
and the underlying classes.
Be aware that flush (which writes out any buffered characters) is invoked by endl,
so any statements written similar to the following should work as you were
expecting :
  std::cout << "your text here" << std::endl ;

HTH,
  Mike Young

-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
Behalf Of enggakshat
Sent: Wednesday, November 15, 2006 12:58 PM
To: gcc-help@gcc.gnu.org
Subject: Re: is the c code in gcc comiled sequentially???





Ian Lance Taylor-3 wrote:
> 
> enggakshat <enggakshat@yahoo.com> writes:
> 
>> for the following simple code i thought its obvious that 'hello' is
>> printed
>> but that doesnt happen.
>> as far as i knew the code is executed sequentially. 
>> 
>> #include<iostream>
>> 
>> using namespace std;
>> 
>> int main()
>> 
>> {
>>  int i=0;
>>  cout<<"hello";
>>  while(1)
>>  {
>>   i++;
>>  }
>> }
> 
> This is most likely a buffering issue.  std::cout is normally line
> buffered by default, which means that it is only flushed when you
> output a newline character.  Try this:
>     cout << unitbuf << "hello";
> 
> Ian
> 
> 
thanks a lot .it worked.is there any suggested reading from where i can get
more info on buffers in c++

regards
Akshat
-- 
View this message in context: http://www.nabble.com/is-the-c-code-in-gcc-compiled-sequentially----tf2634251.html#a7362882
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: is the c code in gcc comiled sequentially???
@ 2006-11-15 16:15 Kaz Kylheku
  0 siblings, 0 replies; 9+ messages in thread
From: Kaz Kylheku @ 2006-11-15 16:15 UTC (permalink / raw)
  To: enggakshat, gcc-help

enggakshat wrote:
> i m a newbie to gcc and i have been making a project lately 
> on netwoking.
> yesterday i encountered a starnge situation wherein it so 
> happened that d
> program that i made was not sequentially executed.any ideas 
> so as to why?

Uh huh, it can't /possibly/ be your buggy code.

The only explanation is that the the compiler is not executing
statements sequentially.

Or could it be that it's actually throwing away the stuff between /* and
*/ ?

> ask for the code details if required

What for? It's perfect; that's not where the problem is.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-11-15 19:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-15  6:13 is the c code in gcc comiled sequentially??? enggakshat
2006-11-15 12:20 ` John Love-Jensen
2006-11-15 15:07   ` enggakshat
2006-11-15 15:35     ` Ian Lance Taylor
2006-11-15 17:57       ` enggakshat
2006-11-15 19:18         ` Young, Michael
2006-11-15 15:38     ` John Love-Jensen
2006-11-15 17:55       ` enggakshat
2006-11-15 16:15 Kaz Kylheku

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).