Difference between Unix and Linux for resolving symbols


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Difference between Unix and Linux for resolving symbols
# 8  
Old 10-18-2012
the version is
(cc -V)

cpp.ansi: HP92453-01 B.11.11.20 HP C Preprocessor (ANSI)
ccom: HP92453-01 B.11.11.20 HP C Compiler

HPUx...

(uname -r)
B.11.23

which means it should be HP-UX 11i v2

the output being displayed is

./test

0

(as it is extern variable)
# 9  
Old 10-18-2012
"extern" means "don't allocate any memory for this variable -- assume it already exists". Except it doesn't -- you've never actually defined it anywhere -- so the assumption ends up being wrong. When the linker looks for it, it can't find it.

HP's linker really ought to complain, too. A linker's not supposed to just invent nonexistent variables for you. I can imagine that causing really weird bugs someday.

Here's how it's supposed to work:

Code:
$ cat myextern.c

#include "myextern.h"

// This actually defines the contents of the variable.
// This is what actually makes the variable exist.
int myextern=3;

$ cat myextern.h

#ifndef __MYEXTERN_H__
#define __MYEXTERN_H__

extern int myextern;

#endif/*__MYEXTERN_H__*/

$ cat uses-extern.c

#include <stdio.h>
#include "myextern.h"

int main(void)
{
        printf("myextern = %d\n", myextern);
        return(0);
}

$


Last edited by Corona688; 10-18-2012 at 03:49 PM..
# 10  
Old 10-18-2012
I totally agree that what I am trying to do in the code in HPUx is completely illogical.
That's why I was expecting the error during the executable formation in HPUx also.

But I was surprised by what actually happened over there.
So I was just wondering if there is any difference in the handling for symbols in both linkers or possibly just a loose checking (/bug) on HPUx side.
# 11  
Old 10-19-2012
Quote:
Originally Posted by shamrock
Isnt function and routine the same thing so state your problem clearly...
Actually, according to Niklas Wirth, it isn't: "routine" is a collective term for "procedures" and "functions". "Function" being a routine with exactly one return value, whereas "procedure" is a routine with no return value at all.

C blurs this difference by treating everything as a function, but PASCAL and similar languages don't. The closest analogon to a "procedure" in C would be a function defined to return "void".

bakunin
# 12  
Old 10-19-2012
Quote:
Originally Posted by bakunin
Actually, according to Niklas Wirth, it isn't: "routine" is a collective term for "procedures" and "functions". "Function" being a routine with exactly one return value, whereas "procedure" is a routine with no return value at all.

C blurs this difference by treating everything as a function, but PASCAL and similar languages don't. The closest analogon to a "procedure" in C would be a function defined to return "void".

bakunin
You are right bakunin i got confused between routine and subroutine...Smilie

---------- Post updated at 01:24 PM ---------- Previous update was at 01:21 PM ----------

Quote:
Originally Posted by snowline84
I totally agree that what I am trying to do in the code in HPUx is completely illogical.
That's why I was expecting the error during the executable formation in HPUx also.
I think that the version of your C compiler is very old so you should get a new one or install gcc which is free of cost...
Quote:
Originally Posted by snowline84
But I was surprised by what actually happened over there.
So I was just wondering if there is any difference in the handling for symbols in both linkers or possibly just a loose checking (/bug) on HPUx side.
Can you post the output of "uname -a" on your hpux system...
# 13  
Old 10-30-2012
here is what uname -a gives


HP-UX srv_name B.11.23 U 9000/800 srv_name unlimited-user license
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Difference between UNIX and Linux

hi experts please tell me the real difference between unix and linux at kernel structure (1 Reply)
Discussion started by: linurag
1 Replies

2. Red Hat

Difference in conflict resolving between yum and rpm installs

Hi Guys, I am trying to test installation of a local rpm to my RHEL5 server. I am expecting it to fail as a previous version of the same package name exists. On using rpm -i this behaves as expected but yum install does not pick up the conflict. Here is the element of my SPEC file with the... (5 Replies)
Discussion started by: gazza-o
5 Replies

3. UNIX for Dummies Questions & Answers

difference between unix and linux

Hi I am new to linux I have dout waht is the difference between UNIX and LINUX Is there any soft for insatallation for UNIX OS Thanks (0 Replies)
Discussion started by: sanjaya
0 Replies

4. Shell Programming and Scripting

difference in unix vs. linux sort

Hi, I am using some codes that have been ported from unix to linux, and now the sorting no longer results in the desired ordering. I'm hoping to find a way to mimic the unix sort command in linux. The input file is structured the following: $> cat file.txt... (6 Replies)
Discussion started by: aj.schaeffer
6 Replies

5. AIX

difference between AIx and Linux and Unix

Sir , Can any body explain the difference between linux , Unix and AIx on command Reference all the command on AIx and unix is same or not please reply (2 Replies)
Discussion started by: arif185
2 Replies

6. UNIX for Advanced & Expert Users

What is the difference between Unix & linux

:confused: Hi All Can anyone help me in finding the answer of the question mentioned below. What is the difference between Unix & linux ? Thanks in Advance to all CSaha (1 Reply)
Discussion started by: csaha
1 Replies

7. UNIX for Dummies Questions & Answers

Difference between UNIX and Linux

OK, I've used various versions of UNIX(Solaris, HPUX, etc..) over the years. Now the organization I work for is leaning towards more Linux based systems(Redhat, Suse, etc..) I do see differences in in comands and how to accomplish basic adminstration, but nothing mind blowing. So, what is it... (5 Replies)
Discussion started by: pbonilla
5 Replies

8. UNIX for Dummies Questions & Answers

difference between unix and linux?

Ok, I'm confused. Can someone answer these (stupid) questions please for me? 1. What is the difference between unix and linux? 2. Is FreeBSD a unix distribution? 3. If not, then what is Unix? I actually gone to Unix.com because I thought this is it's official website where I could download... (1 Reply)
Discussion started by: RellioN
1 Replies

9. Programming

Difference Between Unix and Linux Envoriment

This may/may not be a long answer to a short question. I am learning the C programming language at home.I have seen some good books on the UNIX programming enviroment.However, there were a few books that hinted towards the Linux programming enviroment.Is there any difference between the two as... (1 Reply)
Discussion started by: perrylx
1 Replies
Login or Register to Ask a Question