f



compiling on different compilers

I am working on a set of functions that involve dynamic memory
allocation.  I started working with gcc and then moved to Pacific C. 
The reason was that my only access to gcc was through an ssh
connection that I did not have access to all the time, so I got
Pacific so I could work on my home windows computer.

Then I moved back to gcc, which saved me from some major mistakes. 
Somehow Pacific C was letting me get away with stuff that was
completely wrong.  gcc immediately gave me segmentation errors until I
got every last thing correct.

Is gcc the best for catching mistakes?  If not, which one is?
0
mail68 (11)
8/11/2004 10:14:24 PM
comp.lang.c 30657 articles. 4 followers. spinoza1111 (3246) is leader. Post Follow

14 Replies
1352 Views

Similar Articles

[PageSpeed] 47

MJL wrote on 12/08/04 :
> I am working on a set of functions that involve dynamic memory
> allocation.  I started working with gcc and then moved to Pacific C. 
> The reason was that my only access to gcc was through an ssh
> connection that I did not have access to all the time, so I got
> Pacific so I could work on my home windows computer.

Assuming Windows, you can do the same at home. gcc is a very common C 
compiler used in DJGPP, Mingw, Dev-C++ etc. or even standalone at 
command line.

> Then I moved back to gcc, which saved me from some major mistakes. 
> Somehow Pacific C was letting me get away with stuff that was
> completely wrong.  gcc immediately gave me segmentation errors until I
> got every last thing correct.
>
> Is gcc the best for catching mistakes?  If not, which one is?

It's good, but PCLint (test only, no compile) goes further. Note that 
tools don't catch all mistakes. There is nothing like a review by an 
experienced programmer (like you [are]/[will be]).

-- 
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

"C is a sharp tool"

0
emdel (952)
8/12/2004 12:17:06 AM
Emmanuel Delahaye wrote:
> MJL wrote on 12/08/04 :
>>
.... snip ...
>>
>> Is gcc the best for catching mistakes?  If not, which one is?
> 
> It's good, but PCLint (test only, no compile) goes further. Note
> that tools don't catch all mistakes. There is nothing like a
> review by an experienced programmer (like you [are]/[will be]).

splint (nee lclint) is also good, but limited to C (no C++).  It
is also considerably cheaper.

-- 
"Churchill and Bush can both be considered wartime leaders, just
 as Secretariat and Mr Ed were both horses." -     James Rhodes.
"A man who is right every time is not likely to do very much."
  -                            Francis Crick, co-discover of DNA


0
cbfalconer (19194)
8/12/2004 3:23:50 AM
Thanks for the info.

I am writing a set of functions which operate on a linked list of a
struct which holds a string.  I started working on it in the interest
of maximum portability of my code.  I have found since that I really
enjoy working with char* strings, linked lists, malloc etc...

My biggest mistake that slipped by that other compiler was something
like:

mystruct* pm;

pm = (mystruct*)malloc(sizeof(mystruct*));

which should have been:

pm = (mystruct*)malloc(sizeof(mystruct));

I was allocating memory for the size of the pointer and not the actual
struct.

also:

void init(mystruct* pm)
{
   pm = (mystruct*)malloc(sizeof(mystruct));
   pm->first = NULL;
   pm->second = NULL;
}

Here I was trying to change what pm pointed to, not the contents of
the memory being pointed to.  When the function returned, the pointer
pm still pointed to whatever it was pointing to before the function
call.

For small examples, the one compiler was letting me get away with my
mistakes.  gcc caused my program to give the segmentation fault error
every time until I fixed all mistakes.  Thanks again.

mjl
0
mail68 (11)
8/12/2004 4:16:41 PM
MJL wrote on 12/08/04 :
> My biggest mistake that slipped by that other compiler was something
> like:
>
> mystruct* pm;
>
> pm = (mystruct*)malloc(sizeof(mystruct*));
>
> which should have been:
>
> pm = (mystruct*)malloc(sizeof(mystruct));

You should try another programming style, like the one recommended on 
this forum:

mystruct* pm = malloc (sizeof *pm);

because it's exactly what you want.

-- 
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

"C is a sharp tool"

0
emdel (952)
8/12/2004 4:34:53 PM
MJL wrote:
> 
.... snip (handled by ED) ...
> 
> void init(mystruct* pm)
> {
>    pm = (mystruct*)malloc(sizeof(mystruct));
>    pm->first = NULL;
>    pm->second = NULL;
> }
> 
> Here I was trying to change what pm pointed to, not the contents
> of the memory being pointed to.  When the function returned, the
> pointer pm still pointed to whatever it was pointing to before
> the function call.
> 
> For small examples, the one compiler was letting me get away with
> my mistakes.  gcc caused my program to give the segmentation fault
> error every time until I fixed all mistakes.  Thanks again.

With gcc you should use "-W -Wall -ansi -pedantic" when developing
portable code, i.e. most of the time.

Here you have the same error as pointed out by ED before, and also
have developed a memory leak.  You have received a pointer from
malloc, and discarded it when returning.  Try:

mystruct* createmystruct(void) 
{
   mystruct *pm;

   if (pm = malloc(sizeof *pm)) {
      pm->first = pm->second = NULL;
   }
   return pm;
}

-- 
Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!


0
cbfalconer (19194)
8/12/2004 6:17:37 PM
> > pm = (mystruct*)malloc(sizeof(mystruct));
> 
> You should try another programming style, like the one recommended on 
> this forum:
> 
> mystruct* pm = malloc (sizeof *pm);
> 
> because it's exactly what you want.


hmmm...

Is my version an error or just not the recommended style?  I may be
wrong, but the two versions seem equivalent.

mystruct* pm = (mystruct*)malloc(sizeof(mystruct));

pointer of type mystruct* is being pointed to an allocation of enough
memory for a structure of type mystruct.

compare to:

 mystruct* pm = malloc (sizeof *pm);

pointer of type mystruct* is being pointed to an allocation of enough
memory for the structure that pm points to (which is a mystruct).

I accept the second version if this is standard, but it gives me an
uneasy feeling of being a circular argument.  I based my version on
the string version which I have seen in print I think:

char* str = (char*)malloc(sizeof(char))

I was just wondering if my version is incorrect and will cause errors,
because so far it is working ok.  I will of course, for clarity of my
code and compliance with standard practices, change to the accepted
version regardless.

-mjl
0
mail68 (11)
8/12/2004 11:51:03 PM
MJL wrote on 13/08/04 :
>>> pm = (mystruct*)malloc(sizeof(mystruct));
>> 
>> You should try another programming style, like the one recommended on 
>> this forum:
>> 
>> mystruct* pm = malloc (sizeof *pm);
>> 
>> because it's exactly what you want.
>
> Is my version an error or just not the recommended style?  I may be
> wrong, but the two versions seem equivalent.

They have the same behaviour. Just one is much simpler to use and 
maintain than the other. The choice is up to you.

-- 
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

"C is a sharp tool"

0
emdel (952)
8/12/2004 11:55:41 PM
MJL <mail@affordablemedicalsoftware.com> wrote:
>> > pm = (mystruct*)malloc(sizeof(mystruct));
>> 
>> You should try another programming style, like the one recommended on 
>> this forum:
>> 
>> mystruct* pm = malloc (sizeof *pm);
>> 
>> because it's exactly what you want.


> hmmm...

> Is my version an error or just not the recommended style?  I may be
> wrong, but the two versions seem equivalent.

> mystruct* pm = (mystruct*)malloc(sizeof(mystruct));

> pointer of type mystruct* is being pointed to an allocation of enough
> memory for a structure of type mystruct.

> compare to:

>  mystruct* pm = malloc (sizeof *pm);

> pointer of type mystruct* is being pointed to an allocation of enough
> memory for the structure that pm points to (which is a mystruct).

> I accept the second version if this is standard, but it gives me an
> uneasy feeling of being a circular argument.  I based my version on

Luckily, there isn't anything circular - when you initialize 'pm'
(e.g. by calling malloc()) the compiler already knows what 'pm'
and, more important, what its type is.

> the string version which I have seen in print I think:

> char* str = (char*)malloc(sizeof(char))

> I was just wondering if my version is incorrect and will cause errors,
> because so far it is working ok.  I will of course, for clarity of my
> code and compliance with standard practices, change to the accepted
> version regardless.

No, your version is not wrong. You can cast the return value of
malloc() and you can use sizeof(type) without any problems at all.
But most regulars here (with the notable exception of Mr. Plauger,
but who, as far as I understand it, is more concerned with code
that compiles cleanly with both a C and and a C++ compiler) feel
that casting malloc()'s return value isn't to be recommended
because it does not buy you anything (except acceptance by a C++
compiler) but can keep the compiler from warning you if you have
forgotten to include <stdlib.h> - an argument that seems to have
even convinced K&R since in their errata page for K&R2 they
retract their previously recommmendation of using the cast.

In the same sense using e.g. "sizeof(mystruct)" is absolutely
correct. But again there seems to be some kind of consensus here
that there are advantages of using the other form where not the
type but the name of the variable is used. The argument for this
is mostly about the fact that when you use the type you have to
replace it everywhere in your code if the name gets changed,
which, according to Murphy's law, will result in you overlooking
it in the place where it can do the maximum damage. Using the name
of the variable can help you avoid that since you have to change
the word "mystruct" only at the places where you define variables
of that type (which, at least in C89, tends to be mostly near the
start of functions) and you have a better chance of finding all
instances where you have to change them or at least less places
where you can make mistakes. While that may seem to be a small
benefit when you have a 100 lines program it can make quite a
bit of a differences when you have to go through several dozends
of source files, each with several hundreds or more lines. And,
of course, an even more convincing argument is lazyness;-)

                                    Regards, Jens
-- 
  \   Jens Thoms Toerring  ___  Jens.Toerring@physik.fu-berlin.de
   \__________________________  http://www.toerring.de
0
8/13/2004 12:56:11 AM
Jens.Toerring@physik.fu-berlin.de wrote:
> [ concerning malloc() style ]
> In the same sense using e.g. "sizeof(mystruct)" is absolutely
> correct. But again there seems to be some kind of consensus here
> that there are advantages of using the other form where not the
> type but the name of the variable is used. The argument for this
> is mostly about the fact that when you use the type you have to
> replace it everywhere in your code if the name gets changed,
> which, according to Murphy's law, will result in you overlooking
> it in the place where it can do the maximum damage. [...]

     IMHO that's really not a particularly compelling
reason.  A much stronger reason is that the recommended
style avoids exactly the error the O.P. encountered:

 > mystruct* pm;
 > pm = (mystruct*)malloc(sizeof(mystruct*));

.... where the byte count given to malloc() is (probably)
incorrect.

     A possibly more common variant of this error crops
up in programs that have several different struct types
floating around:

	typedef struct { ... } PacketHeader;
	typedef struct { ... } MessageHeader;
	typedef struct { ... } ImageHeader;
	typedef struct { ... } FileHeader;
	typedef struct { ... } GratefulDeader;
	...
	MessageHeader *p;
	...
	p = malloc(sizeof(PacketHeader));

Again, the `malloc(sizeof *p)' style makes this kind of
mistake impossible.  That, I think, is the principal reason
to prefer it.

-- 
Eric.Sosman@sun.com

0
Eric.Sosman (4552)
8/13/2004 2:17:35 PM
On Fri, 13 Aug 2004, Eric Sosman wrote:

>     A possibly more common variant of this error crops
> up in programs that have several different struct types
> floating around:
> 
>        typedef struct { ... } PacketHeader;
>        typedef struct { ... } MessageHeader;
>        typedef struct { ... } ImageHeader;
>        typedef struct { ... } FileHeader;
>        typedef struct { ... } GratefulDeader;
>        ...
>        MessageHeader *p;
>        ...
>        p = malloc(sizeof(PacketHeader));
> 
> Again, the `malloc(sizeof *p)' style makes this kind of
> mistake impossible.  That, I think, is the principal reason
> to prefer it.

PacketHeader *p;
MessageHeader *q;
ImageHeader *r;
FileHeader *s;
GratefulDeader *t;
....
p = malloc(sizeof *p);
q = malloc(sizeof *p);
r = malloc(sizeof *p);
s = malloc(sizeof *p);
t = malloc(sizeof *p);
0
jwuolijo (92)
8/13/2004 7:38:12 PM
Jarno A Wuolijoki wrote:
> On Fri, 13 Aug 2004, Eric Sosman wrote:
> 
> 
>>    A possibly more common variant of this error crops
>>up in programs that have several different struct types
>>floating around:
>>
>>       typedef struct { ... } PacketHeader;
>>       typedef struct { ... } MessageHeader;
>>       typedef struct { ... } ImageHeader;
>>       typedef struct { ... } FileHeader;
>>       typedef struct { ... } GratefulDeader;
>>       ...
>>       MessageHeader *p;
>>       ...
>>       p = malloc(sizeof(PacketHeader));
>>
>>Again, the `malloc(sizeof *p)' style makes this kind of
>>mistake impossible.  That, I think, is the principal reason
>>to prefer it.
> 
> 
> PacketHeader *p;
> MessageHeader *q;
> ImageHeader *r;
> FileHeader *s;
> GratefulDeader *t;
> ...
> p = malloc(sizeof *p);
> q = malloc(sizeof *p);
> r = malloc(sizeof *p);
> s = malloc(sizeof *p);
> t = malloc(sizeof *p);

     Well, yes -- but only the first of these forms matches
the recommended style.  In all the other cases it's easy to
spot the error by inspecting the one line alone, without
scrolling around trying to find the declaration of `q' or
`r' or whatever.  If you see

	ptr = malloc(sizeof *ptr);

(and if the compiler does not complain that `ptr' is not a
pointer), you know at once that the correct amount of
memory has been requested.  On the other hand, if you see

	ptr = malloc(sizeof(BucketOfBits));

you cannot tell whether it's right or wrong without hunting
up the actual declaration of `ptr'.  The recommended style
localizes all that's needed for a correctness proof.

     Of course, it's still possible to make errors in memory
allocation, even with the recommended form!

	ptr = malloc(n * sizeof *ptr);
	if (ptr != NULL) {
	    while (n >= 0)
	        ptr[n--] = expression;
	}

will not be caught by the suggested style.  Seat belts save
lives, but not every life in every crash.

-- 
Eric.Sosman@sun.com

0
Eric.Sosman (4552)
8/13/2004 8:54:47 PM
mail@affordablemedicalsoftware.com (MJL) wrote in message news:<29c5bb08.0408121551.16c6f04f@posting.google.com>...
> 
> Is my version an error or just not the recommended style?  I may be
> wrong, but the two versions seem equivalent.
> 
> mystruct* pm = (mystruct*)malloc(sizeof(mystruct));
> 
> compare to:
> 
>  mystruct* pm = malloc (sizeof *pm);

The two are equivalent, but most people consider your version to
be more error prone, and poor style, for a number of reasons:

- casting the return value from malloc() may hide a bug if
  you forget to include the correct header file to declare
  malloc(). In this case, the compiler is required to give
  you a diagnostic if there is no cast. Many compilers will
  give you a warning even if you do have the cast, but there
  is no guarantee that they will and you may need to switch
  on a particular warning level.

- using <sizeof *pm> makes the code more self-adjusting in
  case of change. Suppose you want to change the type of this
  storage area to <herstruct>. In your version, you need to
  remember to change the type in two places (three if you keep
  the cast), and failing to do so will result in a silent bug
  that may cause buffer overruns. In the widely preferred
  version, you change the type in one place and everything
  else adjusts automatically.

- casting the return value from malloc() is simply not necessary.
  Having unnecessary stuff in the code makes it harder to
  maintain, and more prone to error during maintenance. When I
  see your version, I have to work out what the cast is doing
  and why it is there. This wastes my time, and makes it more
  likely that I will misinterpret what the code does simply
  because there is more code for me to interpret.

- it takes more typing for no benefit.

> I accept the second version if this is standard, but it gives me an
> uneasy feeling of being a circular argument.

Don't be uneasy - that's what's good about it! Everything on
the line that depends on the type of the object depends on the
same mention of the type.

> I based my version on
> the string version which I have seen in print I think:
> 
> char* str = (char*)malloc(sizeof(char))

In that case, I would throw away that bit of print. There are an
awful lot of bad books on C, and even more bad advice on the net.

> I was just wondering if my version is incorrect and will cause errors,
> because so far it is working ok.

It's correct and will not of itself cause errors as it stands. It
might hide another error (omit the declaration of malloc() and
you'll end up with a run-time error in some 64-bit environments,
for example). It is more prone to error if ever you modify it.

> I will of course, for clarity of my
> code and compliance with standard practices, change to the accepted
> version regardless.

Very wise!
0
jjf (517)
8/13/2004 9:33:58 PM
On 12 Aug 2004 16:51:03 -0700, in comp.lang.c ,
mail@affordablemedicalsoftware.com (MJL) wrote:

>> > pm = (mystruct*)malloc(sizeof(mystruct));
>> 
>> You should try another programming style, like the one recommended on 
>> this forum:
>> 
>> mystruct* pm = malloc (sizeof *pm);
>> 
>> because it's exactly what you want.
>
>
>hmmm...
>
>Is my version an error or just not the recommended style?  I may be
>wrong, but the two versions seem equivalent.

They're technically equivalent, but the CLC_recommended version has two
benefits:
a) the cast in your version is superfluous (in C code), and can even hide
errors such as failing to #include the right header

b) the use of *object over (type) makes your code more maintainable.

-- 
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
0
markmcintyre (4555)
8/13/2004 11:19:49 PM
On Fri, 13 Aug 2004 22:38:12 +0300, in comp.lang.c , Jarno A Wuolijoki
<jwuolijo@cs.Helsinki.FI> wrote:

>On Fri, 13 Aug 2004, Eric Sosman wrote:
>
>>     A possibly more common variant of this error crops
>> up in programs that have several different struct types
>> floating around:
>> 
>>        typedef struct { ... } PacketHeader;
>>        typedef struct { ... } MessageHeader;
.....
>>        MessageHeader *p;
>>        ...
>>        p = malloc(sizeof(PacketHeader));
>> 
>>That, I think, is the principal reason  to prefer it.
>
>PacketHeader *p;
>MessageHeader *q;
>...
>p = malloc(sizeof *p);
>q = malloc(sizeof *p);

But this mistake is much easier to spot, IMHO, since the LHS of the
expression is different to the operand of sizeof. Whereas in the original,
without instant access to the definition of p, you have no way to know
whether the malloc statement is wrong. 
-- 
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
0
markmcintyre (4555)
8/13/2004 11:22:03 PM
Reply:

Similar Artilces:

program that compiles in C compiler but not in C++ compiler
Hi, I need a small program that compiles in C compiler but not in C++ compiler. Thx in advans, Karthik Balaguru KBG <karthik.balaguru@lntinfotech.com> wrote: > I need a small program that compiles in C compiler but not in C++ > compiler. No problem, just send $10 to paypal@zevv.nl and I'll do your homework for you. -- :wq ^X^Cy^K^X^C^C^C^C KBG said: > Hi, > > I need a small program that compiles in C compiler but not in C++ > compiler. Can you think of any syntactic differences between C and C++? For example, what about keywords? They are very, very sen...

Are sun studio C/C++ compilers and Forte C/C++ compilers same ??
Is there any difference between sun studio compilers and forte compilers??? or the names have been changed??? In article <1145338052.955429.256610@v46g2000cwv.googlegroups.com>, "ameya_agnihotri" <ameyaagnihotri22@gmail.com> writes: > Is there any difference between sun studio compilers and forte > compilers??? > or the names have been changed??? One of many name changes in the product's history (including amongst others, Java somethingortheother, Workshop, Proworks/Teamworks, and probably more I've forgotten). Of course, the versions and features cha...

The perils of mixing C compiled with different compilers into the same executable.
A project that has landed in my lap (i.e. not my code) is written in C++ on Solaris 8. It uses a third-party library written in C. The vendor of that library is using GCC 3.4.x to compile it. They are really using the = C compiler from GCC, not the C++ one (i.e. not g++). We are using the ancient Sparcworks 4.2 C++ compiler (not my choice). My question is: "is it safe to combine C++ from one vendor compiler with C from GCC?".=20 I know why it is not safe to combine C++ from different compiler, due to there being no ABI. But there is an ABI for C (i.e. ELF which superceeds ...

Compiling Compiler
Hi there, I need some advice/opinion of the experts out there regarding compilers. I have sun cc compiler that supports 64 bit environment. Now, I compile ACK using this compiler.This should give a compiler that supports 64bit environment. Since the output files are in Solaris format, I compile the ACK source *once again* using the just compiled ACK compiler so that I get Minix object and binary files. Now my questions is that does this 2nd version of ACK be able to produce true 64bit code? Sanky wrote: > Hi there, > > I need some advice/opinion of the experts out there regarding...

Compiled or not compiled
I need to distinguish between two situations: one when a Matlab function is run from Matlab command window and the other one when it is run in compiled mode. Any ideas how to do this? Thanks Tomy Duby "Tomy Duby" <tomy.duby@agilent.com> wrote in message news:idq8q8$85k$1@fred.mathworks.com... > I need to distinguish between two situations: one when a Matlab function > is run from Matlab command window and the other one when it is run in > compiled mode. > Any ideas how to do this? HELP ISDEPLOYED. -- Steve Lord slord@mathworks.com comp.s...

To compile or not to compile
Is there some benefit in compiling the apache source yourself? -- //Points ------------------------------------------------------------ http://underthebed.homeip.net ...

which compiler compiled?
Is there a way I can tell which compiler compiled an executable? I looked at the file with a hex editor and didn't see anything obvious. Lawrence "Lawrence" <just4me@nowhere.com> writes: > Is there a way I can tell which compiler compiled an executable? Yes with some compilers and some executable formats. E.g. on HP-UX for PA-RISC: $ aCC leak.C $ odump -compunit a.out ... 6 0 ANSI C++ leak.C /tmp ctcom options = -inst compiletime -diags 523 -inline_power 1 -longbranch 2 -unique_strings on -cachesize 256 B...

compiling c code but libraries are compiled in c++
hi, We have written cunit code for testing some APIs. defination of those APIs are in c++ and .so library is created of them. when I compile my cunit code it gets compiled successfully but while liking it gives undefined reference to symbol. can anyone help me in this matter. Regards Sumit Shrivastava On 29 May 2007 04:11:14 -0700 sumit <sumit.shrivastava09@gmail.com> wrote: | We have written cunit code for testing some APIs. defination of | those APIs are in c++ and .so library is created of them. when I | compile my cunit code it gets compiled successf...

To compile or not to compile
Is there some benefit in compiling the apache source yourself? -- //Points ------------------------------------------------------------ http://underthebed.homeip.net ...

Will C pgm compile on C++ compiler?
I had C programming in school years ago and would like to play with it again. When I go online I only seem to be able to find C++ compilers. I know that C++ is object oriented, whereas C is not. I can get a good price on Visual C++ 6.0. Is there a way to run native C programs on a C++ compiler? Thanks, Ken [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] "Ken Applequist" <apple07840@yahoo.com> wrote in message news:<Sh%1d.4320$F75.1229@trndny01>... > I had C programming in school ...

Compile or not compile?
There's something that sometimes in while it bores me a little bit. How do I know if I need to compile a function/procedure or it will be able to compile "on fly". At the beginning I thought this was related to the paths idl "knew", but this happens for two functions/routines in the same directory. Can someone tell when a function can be runned without be compile? Nuno Oliveira wrote: > There's something that sometimes in while it bores me a little bit. How > do I know if I need to compile a function/procedure or it will be able > to compile &quo...

Re: Will C pgm compile on C++ compiler?
Ken Applequist wrote: > I had C programming in school years ago and would like to play with it > again. When I go online I only seem to be able to find C++ compilers. I know > that C++ is object oriented, whereas C is not. I can get a good price on > Visual C++ 6.0. Is there a way to run native C programs on a C++ compiler? Several authors implied that a C++ compiler can compile C programs. This is only correct with some restrictions. For example, you can obviously not use C++ keywords as identifiers. For example, the following is a legal C program but will fail using C++: in...

commercial c compilers vs free c compilers
what are the benefits in using commercial compilers like intel, greenhill or portland compared to free c compiles like gcc, lcc, tcc, TenDRA, sun and others? geletine wrote: > what are the benefits in using commercial compilers like intel, > greenhill or portland compared to free c compiles like gcc, lcc, tcc, > TenDRA, sun and others? > <mostly non-topical> As we have no idea of your interests, potential benefits may not be meaningful in your projects. More than one of these commercial compilers is more efficient about vectorization, although gcc is closing the gap. <...

link a c compiled application with a c++ compiled library ?
Hi, I've searched nearly one hour for this but found nothing usefull :-/ So my question is simple : Is it possible to link a c compiled application with a C++ compiled library ?? If yes, how would it possible.. (I guess this would be indirectly posible by using some wrapper around the c++ library, but I'm aboslutely not wanting to do that in my case, well at least if I have to write that wrapper manually myself). I looked at gcc,g++ man pages, gcc online documentation, .. but can't even find a beginning of info related to that :-/ Thank you if you can help me. Regards, ...

Fortran dll compiles, but runs differently, under different compilers
I'm working on a project right now. I'm writing the user interface, which is written in C++. The back-end simulation is written in Fortran. We compile the Fortran into a dll and call it from the C++ program and it works ... some of the time. It works on the old dll which was compiled over a year ago by Microsoft's Visual Fortran compiler. However, now that we've switched over to Compaq's Visual Fortran, we're getting memory access violations when we try to invoke the dll. Do these compilers do anything differently? We can use the old dll for now but it really lim...

Could I compile "c" source with a C++ compiler (Forte C++ Update 2)?
Does Forte C++ Update 2 compiles C source code in ANSI C as same as Forte C udpate 2 does? Jacob, Park <bluejacob@empal.com> wrote: > Does Forte C++ Update 2 compiles C source code in ANSI C as same as > Forte C udpate 2 does? If you're asking whether "CC" will compile the same code as "cc", then the answer is no. This is true for ANY standard-compliant c++ compiler (compilers with different "language mode" like gcc don't count as a single compiler for this description). However, usually one can make C code "compilable" by C++ co...

Compiler compiler with C++ as output
Greetings. Do you know any compiler compiler that can give output in C++? I would like to implement run-time scripting system in my system, and i am looking for fully object-oriented compiler compiler. So far i found only antlr. Any other suggestions? With Best Regards, Andrey Have a look at Yacc++.... http://tarkus.pha.jhu.edu/scienceArchive/design/YACC++.html ~Rajesh "Andrey Batyuck" <javaman@mail.ru> wrote in message > Greetings. > > Do you know any compiler compiler that can give output in C++? I would like > to implement run-time scripting system in...

compiling the kernel with a different compiler
hi! i've searched for a possible sollution on the web & in other groups, found nothing. i want to compile the kernel with a new gcc version (build from a snapshot). it is located in "/opt". i've tried to do "export CC=/opt/bin/gcc; export HOSTCC=/opt/bin/gcc" and used "-B/opt", but the kernel is still build with my default compiler! please help! thanks in advice! V Sat, 13 Jan 2007 17:11:56 -0800, linuxadmin napsal(a): > hi! > > i've searched for a possible sollution on the web & in other groups, > found nothing. > >...

Compiler compiler with C++ as output
Greetings. Do you know any compiler compiler that can give output in C++? I would like to implement run-time scripting system in my system, and i am looking for fully object-oriented compiler compiler. So far i found only antlr. Any other suggestions? With Best Regards, Andrey "Andrey Batyuck" <javaman@mail.ru> wrote > Greetings. > > Do you know any compiler compiler that can give output in C++? I would like > to implement run-time scripting system in my system, and i am looking for > fully object-oriented compiler compiler. > > So far i found only an...

different results for C/C++ compiler
char s[7] = "1234567"; when we use C compiler (gcc), it works fine. An error is reported if using C++ compiler (g++). any story for this one? Vol Vols wrote: > char s[7] = "1234567"; > This is an error since you do not end the array with zero You put 7 chars, in a 7 position array, then the string is not zero terminated. legal in C, illegal in C++. > when we use C compiler (gcc), it works fine. > An error is reported if using C++ compiler (g++). > > any story for this one? > > Vol -- jacob navia jacob at jacob point remcomp point fr lo...

Using macros as function_names (for compiling different function_names with one C-Code via a compile flag)
Hi, Does anybody know how one can use a macro (or something similar) as a function name ? I would like to declare the following functions: FOO_fun1(int) { .... } FOO_fun2(int) { .... } with a compile option (I use gcc) FOO should be substituted by any string. Thank for all suggestions Andreas PS: if anybody wonders, what I'm doing: I'm currently implementing something in Esterel and Esterel will automatically generate me a C-Code-File (for example foo.c). In this file, there will be function calls to some extern declared functions foo_fun1(int), foo_fun2(char* h).... I have t...

compiling Qt .... compiling Qt ....compiling Qt.... compiling Qt
I got myself new kernel from kernel.org... make xconfig needs Qt (new system). So I got new Qt source this afternoon. It is still compiling.... Who said MS is bloat has not done this. What does Qt do? Dunno, how about xforms for xconfig? On Thu, 02 Feb 2006 19:18:09 +0000, Jan Panteltje wrote: > Dunno, how about xforms for xconfig? Why not curses based? menuform -- Hilsen/Regards Michael Rasmussen http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917 On a sunny day (Thu, 02 Feb 2006 21:55:33 +0100) it happened Michael Rasmussen <mir@miras.or...

Cannot compile c/c++ code with Matlab R2009a Lcc compiler
Hello, I am using the lcc compiler in Matlab R2009a to create MEX files. The c/c++ files have previously been compiled and found to work in visual studio, but the matlab compiler appear to expect another syntax: class 'Sample.cpp': #include <stdio.h> #include <math.h> #include "mex.h" static const int nbrOfBands = 1; double FindShortestPath(double fromAngle, double toAngle); double FindShortestPath(double fromAngle, double toAngle, double scanDirection); double FindShortestPath(double fromAngle, double toAngle) { return findShortestPath(fro...

CodeWright Compiler Error Parser Support for GreenHills C/C++ compiler
Hello All I have Version 6.5 of CodeWright (CW) and wish to compile inside of CW using the Greenhills compiler (ie. outside of the GreenHills Multi shell) and get CW to interpret this compilers error codes allowing CW to jump to next error ect. I have done with the Microtec Compiler before. I guess my copy of the errparse.dll is out of date and cannot find a later version of it on the Premia web site. Can anybody provide any pointers, or a later version of this dll that support the GHS compiler. Thanks in advance for any help Robert ...

Web resources about - compiling on different compilers - comp.lang.c

Cool tools for compiling to JavaScript
Every programmer has a favorite language or two. JavaScript lovers are the luckiest these days because their language is taking over the Internet ...

Feds put protest activity under microscope in compiling national 'risk forecast'
Use of social media, the spread of "citizen journalism," and the involvement of young people are among the key trends highlighted by a federal ...

10 Tips For Compiling A Deal Sheet
Compiling a deal sheet is a great way of taking stock of your experience and of seeing where your experience may be lacking.

Compiling 64-Bit Code
Describes the 64-bit features available in OS X.

Is there a benefit to compiling your code as you go?
Stack Exchange This Q&A is part of a weekly series of posts highlighting common questions encountered by technophiles and answered by users ...

6 cool tools for compiling to JavaScript
Every programmer has a favorite language or two. JavaScript lovers are the luckiest these days because their language is taking over the Internet ...

Compiling The Absurd Box Score For Space Jam ; Or, Shawn Bradley Sucked Against Cartoons, Too
This is Regressing, a numbers-minded column by our clever friends at the Harvard College Sports Analysis Collective. Over the next few days, ...

We're Compiling Every Police-Involved Shooting In America. Help Us.
The United States has no database of police shootings. There is no standardized process by which officers log when they've discharged their weapons ...

Flat UI Pro Tutorial: Setting and Compiling Using LESS
In this video tutorial, you use components from Flat UI Pro to create a complete simple mail app using LESS. He takes you through the steps to ...

Industrious 4chan user is compiling a list of every videogame ever made
... me to enter a few hundreds of games into my Backloggery account , and I haven't even finished it yet. Ambitious 4chan user Data_baser is compiling ...

Resources last updated: 2/23/2016 12:40:26 AM