What is the most compiler close to gcc in unix?

What is the most compiler close to gcc in unix?

Post by eha » Wed, 18 Jun 2003 07:03:34



I need to make my programs portable between PC environment and Unix
 environment So , to not alter my code I am asking that question ?
 
 
 

What is the most compiler close to gcc in unix?

Post by Dragan Cvetkovi » Wed, 18 Jun 2003 07:22:29



> I need to make my programs portable between PC environment and Unix
>  environment So , to not alter my code I am asking that question ?

It would help if you can say what is the native platform. Also, gcc runs on
most of UNIX platforms, and it also runs on Win32 (check cygwin) and Mac
OSX.

So, for the lack of more information, the answer is probably: gcc.

Bye, Dragan

--
Dragan Cvetkovic,

To be or not to be is true. G. Boole      No it isn't.  L. E. J. Brouwer

 
 
 

What is the most compiler close to gcc in unix?

Post by M?ns Rullg? » Wed, 18 Jun 2003 07:54:14



> I need to make my programs portable between PC environment and Unix
>  environment So , to not alter my code I am asking that question ?

It is considered good practice to state the question in the body of
the message, and not only in the subject line.

As for the question, it isn't clear to me what you are looking for.
What compiler and operating system do you currently use?

--
M?ns Rullg?rd

 
 
 

What is the most compiler close to gcc in unix?

Post by Bjorn Rees » Thu, 19 Jun 2003 01:00:52



> I need to make my programs portable between PC environment and Unix
>  environment So , to not alter my code I am asking that question ?

Gcc is available on most Unix platforms. However, using the same
compiler on different platforms does not in general ensure portability.
If you use platform-specific system calls the compiler will not be
of much help. There are many good rules of thumb that can be used in
such cases, but if you want a more precise answer, you need to provide
more information about what functionality beyond the C standard you need.
For example, do you use IPC, GUI, threads?
 
 
 

What is the most compiler close to gcc in unix?

Post by Villy Kru » Thu, 19 Jun 2003 23:47:04


On Tue, 17 Jun 2003 16:00:52 +0000,


>> I need to make my programs portable between PC environment and Unix
>>  environment So , to not alter my code I am asking that question ?

>Gcc is available on most Unix platforms. However, using the same
>compiler on different platforms does not in general ensure portability.
>If you use platform-specific system calls the compiler will not be
>of much help. There are many good rules of thumb that can be used in
>such cases, but if you want a more precise answer, you need to provide
>more information about what functionality beyond the C standard you need.
>For example, do you use IPC, GUI, threads?

There are some open source packages which will compile on unix as well
as Windows NT systems.  Looking at those could give some idea about what
needed to be done to be portable.  The Perl, Python, Apache, Openldap, Pine
packages comes to mind,  there are probably several others.

Villy

 
 
 

1. shutdown(s, 2) vs close(s) for closing unix domain sockets

The specification of the shutdown(s, 2) system call is to be "more
dramatic" than the close(s) system call, since any pending data is
lost. However, if you use shutdown(s, 2) instead of close(s) under
Solaris, you will have the nasty surprise to notice that the socket
isn't released at all. This mean that the following client/server
program will block at some stage. Furtermore, if you examine the
socket name space, by netstat -f unix, you will notice that more
than one socket with name "/tmp/foo" is registered by the system...

server.c
--------

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>

main()
{
  int sock, newsock, length;
  struct sockaddr_un name;
  char* buf[1024];

  for(;;)
  {
    sock = socket(AF_UNIX, SOCK_STREAM, 0);

    name.sun_family = AF_UNIX;
    strcpy(name.sun_path, "/tmp/foo");

    bind(sock, (struct sockaddr *)&name, sizeof name);
    listen(sock, 1);
    newsock = accept(sock, (struct sockaddr *) 0, (int *) 0);
    read(newsock, buf, 1024);
    printf("%s", buf);

    shutdown(sock, 2);
    shutdown(newsock, 2);
    unlink(name.sun_path);
  }

/* gcc server.c -o server -lsocket */

client.c
--------

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>

#define DATA "hello world\n"

main()
{
  int sock, length;
  struct sockaddr_un name;

  for(;;)
  {
    sleep(5);
    sock = socket(AF_UNIX, SOCK_STREAM, 0);

    name.sun_family = AF_UNIX;
    strcpy(name.sun_path, "/tmp/foo");

    connect(sock, (struct sockaddr *)&name, strlen(name.sun_path) +
                                          sizeof(name.sun_family));

    write(sock, DATA, sizeof(DATA));
    shutdown(sock, 2);
  }

/* gcc client.c -o client -lsocket */

Now if you simply replace all shutdown(s, 2) by close(s), it works
very well. Under SunOS-4, both calls lead to client/server program
that works. I haven't tested it with internet domain sockets yet.  

Any comment?

          \\|//
          |^ ^|          
          (O O)        
----oo0o---(_)---o0oo-------------------------------------------------------

Benoit Garbinato

Departement d'Informatique               (DI)   phone:  + 41 21 693 52 74
Ecole Polytechnique Federale de Lausanne (EPFL) fax:    + 41 21 693 39 09
CH-1015 LAUSANNE
(Switzerland)

2. Video Driver for Toshiba Tecra 720CDT

3. Is there more user friendly compilers in Unix instead of gcc?

4. GNU C and Lib books

5. Errors compiling Wingz 1.4 Add-ins (Linux 1.3.99, GCC 2.6)

6. RealPlayer link?

7. getchar with gcc using pointers --using gcc not any other compiler

8. linux server emergency

9. XFree86 4.0.2 -- Voodoo3 -- Beige G3 (am I getting close?)

10. nvidia xfree and quake, Am I getting close?

11. Ok I am getting close

12. PPP and IPX, I know I am close....

13. i am close to atlanta.