473,473 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

compilation error in structure

hi,

i wrote this structre. after first compilation i am getting "C uses
undefined struct pcap". what it is so.

struct pcap_hdr {
_int16 version_major; /* major version number */
_int16 version_minor; /* minor version number */
_int32 thiszone; /* GMT to local correction */
_int32 sigfigs; /* accuracy of timestamps */
_int32 snaplen; /* max length in octets */
_int32 network; /* data link type */
}pcap;

main(){

int bytes_read;
int magic;
struct pcap C;
--
--
--
}
Nov 13 '05 #1
8 3303

Puneet <pu************@yahoo.com> wrote in message
news:47*************************@posting.google.co m...
hi,

i wrote this structre. after first compilation i am getting "C uses
undefined struct pcap". what it is so.

struct pcap_hdr _int16 version_major; /* major version number */
_int16 version_minor; /* minor version number */
_int32 thiszone; /* GMT to local correction */
_int32 sigfigs; /* accuracy of timestamps */
_int32 snaplen; /* max length in octets */
_int32 network; /* data link type */
}pcap;

n(){
int bytes_read;
int magic;
struct pcap C;


struct pcap_hdr C;

What you intend to do with the above type 'struct pcap_hdr'
object, named 'pcap' I don't know. :-)

Did you perhaps mean to write a typedef?

-Mike


Nov 13 '05 #2
Puneet wrote:
hi,

i wrote this structre. after first compilation i am getting "C uses
undefined struct pcap". what it is so.

struct pcap_hdr {
_int16 version_major; /* major version number */
_int16 version_minor; /* minor version number */
_int32 thiszone; /* GMT to local correction */
_int32 sigfigs; /* accuracy of timestamps */
_int32 snaplen; /* max length in octets */
_int32 network; /* data link type */
}pcap;

Of course you know already that all those _int16 and _int32 types are
non-portable, non-standard, and off topic here. Leaving that aside, you
have here defined a type 'struct pcap_hdr' and an object of that type
'pcap'. If you mean pcap to be a type, you need to precede 'struct
pcap_hdr' with 'typedef', in which case the tag 'pcap-hdr' is superfluous.


main(){
This should, of course, be 'int main(void)'. main returns an int, and you
should say so. In C99 the implicit int of your form is disallowed, and
it's bad practice anyway.

int bytes_read;
int magic;
struct pcap C;


There is no type 'struct pcap'. This should be 'struct pcap-hdr C;' or, if
you use typedef as I suggested above, just 'pcap C;'.

--
Martin Ambuhl

Nov 13 '05 #3

On Fri, 22 Aug 2003, Puneet wrote:

i wrote this structre. after first compilation i am getting "C uses
undefined struct pcap". what it is so.

struct pcap_hdr { ^^^^^^^^ _int16 version_major; /* major version number */
_int16 version_minor; /* minor version number */
_int32 thiszone; /* GMT to local correction */
_int32 sigfigs; /* accuracy of timestamps */
_int32 snaplen; /* max length in octets */
_int32 network; /* data link type */
}pcap;

main(){

int bytes_read;
int magic;
struct pcap C;

^^^^

http://www.google.com/search?q=c+faq...+Feeling+Lucky

-Arthur

Nov 13 '05 #4
Puneet wrote:

hi,

i wrote this structre. after first compilation i am getting "C uses
undefined struct pcap". what it is so.

struct pcap_hdr {
"I am defining a new struct type called `struct pcap_hdr',
containing the elements listed below."
_int16 version_major; /* major version number */
_int16 version_minor; /* minor version number */
_int32 thiszone; /* GMT to local correction */
_int32 sigfigs; /* accuracy of timestamps */
_int32 snaplen; /* max length in octets */
_int32 network; /* data link type */
}pcap;
"I am defining a variable named `pcap', an instance of
the `struct pcap_hdr' type."
main(){

int bytes_read;
int magic;
struct pcap C;


Compiler: "What is this `struct pcap' you're talking about?
I know about a type named `struct pcap_hdr', and I know about
a variable named `pcap', but I've never heard of `struct pcap'
before. Pppphhhht!"

--
Er*********@sun.com
Nov 13 '05 #5
pu************@yahoo.com (Puneet) wrote:
# hi,
#
# i wrote this structre. after first compilation i am getting "C uses
# undefined struct pcap". what it is so.
#
# struct pcap_hdr {
# _int16 version_major; /* major version number */
# _int16 version_minor; /* minor version number */
# _int32 thiszone; /* GMT to local correction */
# _int32 sigfigs; /* accuracy of timestamps */
# _int32 snaplen; /* max length in octets */
# _int32 network; /* data link type */
# }pcap;
#
# main(){
#
# int bytes_read;
# int magic;
# struct pcap C;

The struct tag is pcap_hdr, and would be used
struct pcap_hdr C;
"pcap" by itself is a global variable name.

--
Derk Gwen http://derkgwen.250free.com/html/index.html
I hope it feels so good to be right. There's nothing more
exhilirating pointing out the shortcomings of others, is there?
Nov 13 '05 #6
pu************@yahoo.com (Puneet) wrote:
# hi,
#
# i wrote this structre. after first compilation i am getting "C uses
# undefined struct pcap". what it is so.
#
# struct pcap_hdr {
# _int16 version_major; /* major version number */
# _int16 version_minor; /* minor version number */
# _int32 thiszone; /* GMT to local correction */
# _int32 sigfigs; /* accuracy of timestamps */
# _int32 snaplen; /* max length in octets */
# _int32 network; /* data link type */
# }pcap;
#
# main(){
#
# int bytes_read;
# int magic;
# struct pcap C;

The struct tag is pcap_hdr, and would be used
struct pcap_hdr C;
"pcap" by itself is a global variable name.

--
Derk Gwen http://derkgwen.250free.com/html/index.html
I hope it feels so good to be right. There's nothing more
exhilirating pointing out the shortcomings of others, is there?
Nov 13 '05 #7
pu************@yahoo.com (Puneet) wrote:
# hi,
#
# i wrote this structre. after first compilation i am getting "C uses
# undefined struct pcap". what it is so.
#
# struct pcap_hdr {
# _int16 version_major; /* major version number */
# _int16 version_minor; /* minor version number */
# _int32 thiszone; /* GMT to local correction */
# _int32 sigfigs; /* accuracy of timestamps */
# _int32 snaplen; /* max length in octets */
# _int32 network; /* data link type */
# }pcap;
#
# main(){
#
# int bytes_read;
# int magic;
# struct pcap C;

The struct tag is pcap_hdr, and would be used
struct pcap_hdr C;
"pcap" by itself is a global variable name.

--
Derk Gwen http://derkgwen.250free.com/html/index.html
I hope it feels so good to be right. There's nothing more
exhilirating pointing out the shortcomings of others, is there?
Nov 13 '05 #8
"Derk Gwen" <de******@HotPOP.com> wrote in message
news:vk************@corp.supernews.com...
| The struct tag is pcap_hdr, and would be used
| struct pcap_hdr C;
| "pcap" by itself is a global variable name.

Someone was impatient with the "Send" button =P
Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Chris Mantoulidis | last post by:
Seperate compilation (that's what it's called, right?) seems to be quite popular, so I decided to get some info about it, and (d'oh) use it... But it's whole structure seems weird to me... ...
11
by: Steven T. Hatton | last post by:
I've made no secret of the fact that I really dislike the C preprocessor in C++. No aspect of the language has caused me more trouble. No aspect of the language has cause more code I've read to be...
10
by: Rick Anderson | last post by:
All, I am receiving the following compilation error on LINUX (but not Solaris, HPUX, WIN32, etc): compiling osr.c LBFO.h(369): warning #64: declaration does not declare anything extern...
10
by: Sune | last post by:
Hi, previously I used Eclipse CDT for compiling my files just to get started with C and leave C++ behind. Now it's time to get a little more serious so I've moved my files to a new workplace and...
0
by: Jason Jefferies | last post by:
I'm currently converting a number of applications written using the MFC in vc++ version 6 into a workable .NET solution. Just trying to build the apps in version 7 without worrying about...
3
by: Dan | last post by:
Hi, I have a problem using an aspx page with a Control on it. I get the following error message Compiler Error Message: CS1595: 'Test.Class2' is defined in multiple places; using definition...
17
by: abdur_rab7 | last post by:
Hi, I am compiling code for nanosleep in CYGWIN. During compilation i get the following error Socket.cc: In method `bool Socket::hangOnConnection(int = 0)': Socket.cc:338: aggregate `struct...
2
by: rsphere | last post by:
my app is running just fine on my home dev box. no compilation errors at all. when i move the whole file structure to my hosted site i get the following error when opening the main page: ...
3
by: subramanian100in | last post by:
Consider the following program: #include <iostream> using namespace std; class Base { public: Base(int x = 0);
5
by: Sujal | last post by:
In below program, I'm getting below compilation errors error C2621: member '_tag_nodes_::node_' of union '_tag_nodes_' has copy constructor error C2621: member '_tag_nodes_::linkednode_' of...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.