?
Solved

storage size of `fstat'isn't known

Posted on 2010-01-03
14
Medium Priority
?
1,954 Views
Last Modified: 2012-05-08
hi,
i have a program that used to run on IBM AIX server now i want to change it to Linux. but am getting some problems. First when i complied it was giving
multiple defination of fstat ()  first defined in /usr/include/sys/stat.h
then i put
#ifndef _SYS_STAT_H
#define _SYS_STAT_H 1
#include <sys/stat.h>
#endif
to eliminate the error but now the error is coming for the variables defined and its structure's enum values. like
storage size of `fstat'isn't known
(defined as->       struct stat fstat1;)
`S_IRWXU' undeclared (first use in this function)
storage size of `err_stat' isn't known
the sys/stat is included, size should be there, what am i doing wrong?
i cant find any help regarding this on the net.
thanks
0
Comment
Question by:asaeed
  • 7
  • 4
  • 3
14 Comments
 
LVL 24

Expert Comment

by:fridom
ID: 26168980
Do you have all includes? It does not look like it:
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>

maybe you'll need stdlib also, but first check the manual pages
man fstat
and see what you can find about includes

Regards
Friedrich
0
 
LVL 2

Author Comment

by:asaeed
ID: 26169063
i do have the all these includes in many header files. and .c files.
now i have done this
#ifndef _SYS_STAT_H
#define _SYS_STAT_H 1
#include <sys/stat.h>
#endif
for all the files where sys/stat.h is used but now i am still getting the following errors but in different places than before.
 `S_IRWXU' undeclared (first use in this function)
 (Each undeclared identifier is reported only once
 for each function it appears in.)
 `S_IRWXG' undeclared (first use in this function)
 `S_IRWXO' undeclared (first use in this function)
0
 
LVL 2

Author Comment

by:asaeed
ID: 26169090
i think this is another error. `S_IRWXU' undeclared (first use in this function)
 not related to the current problem, so do u think that by putting
#ifndef _SYS_STAT_H
#define _SYS_STAT_H 1
#include <sys/stat.h>
#endif
problem is solved????
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
LVL 2

Author Comment

by:asaeed
ID: 26169160
now the mkdir() function has the `S_IRWXU' undeclared (first use in this function)
problem. but i am still getting the storage size of `fstat'isn't known
problem in other modules i am trying to make.
0
 
LVL 7

Accepted Solution

by:
js-profi earned 1000 total points
ID: 26169977
Use
#include <sys/stat.h>

not using macros. AIX headers may have different macro.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26169989
#include <sys/stat.h>
 was already used. i added the ifndef.... my self.  
but its not working. also the
`S_IRWXG' etc.
are defined in sys/stat.h but i dont know why its not workig.
0
 
LVL 24

Assisted Solution

by:fridom
fridom earned 1000 total points
ID: 26170013
It's definitly an include problem, it's a bad idea to just "hack" around bugs. You must check where which stuff is defined and have includes according to that, of course the first assumption is, that the headers are installed. So are they?

If yes you can grep through the headers to find the missing variables

So here S_IRWXU is defined in stat.h (it's a linux box)

Have you checked that the headers whether it's there or not.
a grep on the headers will give you that.


Than have you told you compiler where to look for headers?

Than I suggest you post some code which shows the problem. e.g here I need the following includes
sys/types.h
sys/stat.h
unistd.h

One does not need some stat struct for mkdir, and fstat does not exist as structure in linux, there is a struct stat and  this is the type you should use on Linux.

So you better come up with some code which shows the problem that one can see it, the given information are not sufficient and misleading.

Regards
Friedrich



0
 
LVL 7

Expert Comment

by:js-profi
ID: 26171160
why did you add the macros? it compiles only  some ns faster with them but could give severe problems. then you post 'struct stat fstat1' and error 'fstat' unknown. fstat and fstat1 is pretty different.
0
 
LVL 7

Expert Comment

by:js-profi
ID: 26171173
what do you need the S_IRWXU and err_stat for? those names can be different with different platforms. i never used them.
0
 
LVL 24

Expert Comment

by:fridom
ID: 26172044
You need them on Unices for handling the file system. And those names can be found in POSIX so it's standard on any Unix.
0
 
LVL 2

Author Comment

by:asaeed
ID: 26177579
the header files are available in /usr/include.
i removed the ifndef now the object files are created but at the end i get these errors.
/folder1/convert.o(.text+0x0): In function `fstat':
/usr/include/sys/stat.h:371: multiple definition of `fstat'
./folder1/processin.o(.text+0x0):/usr/include/sys/stat.h:371: first defined here
./folder1/rcon.o(.text+0x0): In function `fstat':
/usr/include/sys/stat.h:371: multiple definition of `fstat'
./folder1/processin.o(.text+0x0):/usr/include/sys/stat.h:371: first defined here
./folder1/readinfo.o(.text+0x0): In function `fstat':
/usr/include/sys/stat.h:371: multiple definition of `fstat'
./folder1/processin.o(.text+0x0):/usr/include/sys/stat.h:371: first defined here
./folder1/dbf.o(.text+0x0): In function `fstat':

the fstat,mkdir function are as follows

mkdir(TmpIndirName,(S_IRWXU | S_IRWXG | S_IRWXO) );
struct stat fstat1;
      stat(outFile, &fstat1);      
struct stat             statbuf;
0
 
LVL 2

Author Comment

by:asaeed
ID: 26177605
compilation syntax is like as follows
cc -g -DMETERSTD -D__IBM__  -DORACLE_DB -D__ENGLISH__ -D__PERFORMANCE__ -D__DBV__ -DPING_BY_SH   -DPOSIX -DMSG -o  fooexe ./folder1/processin.o ./folder1/abc.o ./folder1/f1.o ./folder1/escon.o ./folder1/f1v.o ./folder1/meon.o ./folder1/readinfo.o ./folder1/zw.o ./folder1/dbf.o ./folder1/timewr.o ./folder1/tim.o ./folder1/byder.o ./folder1/reu.o ./folder1/filler.o ./folder1/acquire.o ./folder1/db.o ./folder1/fieq.o ./folder1/qdb.o ./db.o -I/u01/app/oracle/product/9.2.0//precomp/public -lm -I./include -I/u01/app/oracle/product/9.2.0//precomp/public  -I/oracle_install/c.ora -L/oracle_install/c.ora  -L. -L/usr/lib /oracle_install/ctlib.ora/ctlib.o -L/u01/app/oracle/product/9.2.0//lib -lclntsh -lpthread  -L/usr/lib/  -lrt
0
 
LVL 2

Author Closing Comment

by:asaeed
ID: 31672784
thanks i removed the ifndef things and then it was giving the multiple declaration problem. previously i removed __inline__ from the stat.h for fstat (it was giving some problem at that time.) but when i put that back it started to compile. thanks.
0
 
LVL 24

Expert Comment

by:fridom
ID: 26177937
Where's the code you want to compile? Have you stripped it down? What do you think your code tells us?
What the meaning of TmpIndirName, we did not have the slightes clue. You do not even bother to post your include lines, Nothing but error message and "guessworking" this will not work.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question