11-19-2002
Re: answer
Quote:
Originally posted by dbargo
i think that the word "gcc" compile only c file while your main.cpp file is a c++ file
Hi !!
Try this
g++ main.cpp -o main func.o
also plz use g++ even to link c code and allways qualify ur c-functions with -->
#ifdef __CPLUSPLUS
extern "C" {
#endif
<return type> function_name ([args if any]) {
// function body
}
#ifdef __CPLUSPLUS
}
#endif
This is to ensure that ur c-function never face name mangling while getting processed by c++ compiler.
regards
Sachin.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi! I have downloaded a precompiled gcc package but I'm having problems installing it. It is supposed to install in /usr/local and there is plenty of space left there but during the installation I get the following error message “No space left on device”. Is it some kind of temp folder that is out... (2 Replies)
Discussion started by: alfabetman
2 Replies
2. Programming
Hello,
J have a problem when I use gcc:
This comand works:
gcc -shared -fpic -I/usr/include/sys -I/usr/include -L/usr/lib/librt.sl essai1.c mylib.sl
but
gcc I/usr/include/sys -I/usr/include -L/usr/lib/librt.sl essai2.c -o essai
don't work.
The first command creates a dynamique... (1 Reply)
Discussion started by: AUBERT
1 Replies
3. Programming
Hi mates,
I am a new comer of this forums.
I have a problem while using function "fread(buffer, size, number, file-pointer)" to read a binary file.
While I used the "fread()" to read the binary file under Solaris UNIX System, it worked very well. But it gets a incorrect result... (6 Replies)
Discussion started by: cquedugdylp
6 Replies
4. Solaris
Hello All,
I have been using String.h with gcc 2.95. Now I have upgraded to gcc 3.4. The support for String.h has been removed and I believe Regex.h support is also not inbuilt. So I tried to build my own library for String.h. I had to use Regex.h and rx.h for a succesful library compilation.... (0 Replies)
Discussion started by: manishs13
0 Replies
5. Programming
I had this lib which I don't have access to the source code and is created by micosoft Visual C++ compiler ......
Right now I want to reuse this lib as part of my new project which only has gcc as the only compiler...
I had the problem that the lib won't link to my other c code...
my... (2 Replies)
Discussion started by: yuwang
2 Replies
6. Red Hat
I have a host PC and a target system .
Host System -> gcc (3.2) Redhat linux kernel 2.4.20-8 , glibc 2.3
Target System -> gcc (4.1) Fedora linux kernel 2.6.18-1.2798.fc6, glibc 2.5
I would like to build test program that can be run on both systems
---------------------------
... (0 Replies)
Discussion started by: mugdha
0 Replies
7. Solaris
I just installed gcc from the latest package at sunfreeware.com using pkgadd. I write a simple 'Hello World!' program to test it. I try to compile it and I get this error:
rockstar# gcc hello.c -o hello
ld.so.1: gcc: fatal: libiconv.so.2: open failed: No such file or directory
Killed
I... (0 Replies)
Discussion started by: Bradj47
0 Replies
8. Programming
Hi,
I just try to solve the problem why one app failing on box1 and runs ok on box2, they have diff gcc version as I see from /proc/version:
box1:: 3.4.1
box2:: 4.1.2
It's RedHat 64b boxes, so I can not run some <make all> command on box1, do you think I need to upgrade (if I'm using... (1 Reply)
Discussion started by: mario17
1 Replies
9. Programming
Hi everyone,
i made this program. is a simple one for practising malloc, realloc and structs.
I have a struct named shop as global variable in which i take the size of the matrix from the keyboard and after i malloc it.
I insert the values with the fullarray() and after i print the matrix with... (7 Replies)
Discussion started by: giampoul
7 Replies
10. Programming
Dear Linux users,
I'm a noob at openmp, gcc and c programming. I can run my own openmp code in terminal with no problem, eg. gcc -fopenmp program.c -o program.
But now I'm trying to compile and run another person's code, it contains a makefile and multiple .c and .h files. I don't know how to... (2 Replies)
Discussion started by: pigeon151
2 Replies
TYPES(5) BSD File Formats Manual TYPES(5)
NAME
types -- system data types
SYNOPSIS
#include <sys/types.h>
DESCRIPTION
The file sys/types.h contains the defined data types used in the kernel (most are used through out the system).
#ifndef _TYPES_H_
#define _TYPES_H_
typedef short dev_t;
#ifndef _POSIX_SOURCE
/* major part of a device */
#define major(x) ((int)(((unsigned)(x)>>8)&0377))
/* minor part of a device */
#define minor(x) ((int)((x)&0377))
/* make a device number */
#define makedev(x,y) ((dev_t)(((x)<<8) | (y)))
#endif
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef unsigned short ushort; /* Sys V compatibility */
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE)
#include <machine/types.h>
#endif
#ifdef _CLOCK_T_
typedef _CLOCK_T_ clock_t;
#undef _CLOCK_T_
#endif
#ifdef _SIZE_T_
typedef _SIZE_T_ size_t;
#undef _SIZE_T_
#endif
#ifdef _TIME_T_
typedef _TIME_T_ time_t;
#undef _TIME_T_
#endif
typedef u_int64_t u_quad_t;
typedef int64_t quad_t
typedef quad_t * qaddr_t; /* should be typedef quad * qaddr_t; */
typedef long daddr_t;
typedef char * caddr_t;
#ifdef _DARWIN_FEATURE_64_BIT_INODE
typedef u_int64_t ino_t;
#else /* !_DARWIN_FEATURE_64_BIT_INODE */
typedef u_int ino_t;
#endif /* _DARWIN_FEATURE_64_BIT_INODE */
typedef long swblk_t;
typedef long segsz_t;
typedef int64_t off_t;
typedef u_int uid_t;
typedef u_int gid_t;
typedef int pid_t;
typedef u_short nlink_t;
typedef u_short mode_t;
typedef u_long fixpt_t;
#ifndef _POSIX_SOURCE
#define NBBY 8 /* number of bits in a byte */
/*
* Select uses bit masks of file descriptors in longs. These macros
* manipulate such bit fields (the filesystem macros use chars).
* FD_SETSIZE may be defined by the user, but the default here should
* be >= NOFILE (param.h).
*/
#ifndef FD_SETSIZE
#define FD_SETSIZE 1024
#endif
typedef long fd_mask;
#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
#ifndef howmany
#define howmany(x, y) (((x)+((y)-1))/(y))
#endif
typedef struct fd_set {
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
} fd_set;
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
#define FD_COPY(f, t) bcopy(f, t, sizeof(*(f)))
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
#endif /* !_POSIX_SOURCE */
#endif /* !_TYPES_H_ */
SEE ALSO
adb(1), lseek(2), time(3), fs(5)
HISTORY
A types file appeared in Version 7 AT&T UNIX.
Darwin May 15, 2008 Darwin