Error Occured during compilation

A

abdur_rab7

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 timespec tmsp' has incomplete type and
cannot b
e initialized


The Source realted to it is

bool Socket :: hangOnConnection (int nNanoSecond)
{
struct timespec tmsp;
/*tmsp.tv_sec = (time_t) 0;
if (nNanoSecond) tmsp.tv_nsec = nNanoSecond;
else tmsp.tv_nsec = 110;
if (nanosleep (&tmsp, NULL) < 0)
{
DEBUG_MSG ("Error occured during hangOn");
return false;
}*/
return true;
}

"struct timespec" is defined in <sys/types.h>

Please suggest me how to debug it

Best Regards,
Abdur
 
M

Madhav

bool Socket :: hangOnConnection (int nNanoSecond)
{
struct timespec tmsp;
/*tmsp.tv_sec = (time_t) 0;
if (nNanoSecond) tmsp.tv_nsec = nNanoSecond;

Please ask this question in a more appropriate newsgroup.
comp.os.linux.development.* might be a good place.
 
C

Chuck F.

.... snip ...

The Source realted to it is

bool Socket :: hangOnConnection (int nNanoSecond)
^^^^ ^^
Syntax errors.
{
struct timespec tmsp;

Undefined struct.
/*tmsp.tv_sec = (time_t) 0;
if (nNanoSecond) tmsp.tv_nsec = nNanoSecond;
else tmsp.tv_nsec = 110;
if (nanosleep (&tmsp, NULL) < 0)

nanosleep undefined. Missing ')'.
{
DEBUG_MSG ("Error occured during hangOn"); DEBUG_MSG undefined
return false;

false undefined
}*/
return true;

true undefined
}

"struct timespec" is defined in <sys/types.h>

No it isn't. There is no such header file defined in ISO standard
C. What you have here is neither C nor topical. Get thee to a
newsgroupery dealing with your language and/or system. When you
find such post compilable code via cut and paste, not retyping.


--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
 
K

Keith Thompson

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 timespec tmsp' has incomplete type and
cannot b
e initialized


The Source realted to it is

bool Socket :: hangOnConnection (int nNanoSecond)
{
struct timespec tmsp;
/*tmsp.tv_sec = (time_t) 0;
if (nNanoSecond) tmsp.tv_nsec = nNanoSecond;
else tmsp.tv_nsec = 110;
if (nanosleep (&tmsp, NULL) < 0)
{
DEBUG_MSG ("Error occured during hangOn");
return false;
}*/
return true;
}

"struct timespec" is defined in <sys/types.h>

Please suggest me how to debug it

Your code is C++, not C. comp.lang.c++ is down the hall on the left.

Parts of your code could be valid C. I'm suspicious about the "has
incomplete type and cannot be initialized" message, since you don't
actually initialize tmpsp. You say that struct timespec is defined in
<sys/types.h>, but the code you posted doesn't have a #include for
that header.

Write a small, self-contained program that illustrates the problem.
Write it in either C or C++, and post to the appropriate newsgroup.
Post the exact code that you fed to the compiler; don't try to re-type
it or summarize it.
 
R

Rahul Chandok

Hi,

Normally in Solaris compiler (workshop 6 update 2) the defination of
struct timespec is present in sys/time_impl.h, But you don't have to
include this file directly.

Instead of that please include <time.h> this wiill include time_impl.h
implicitly.

If you wish to debug the error, then please run the c preprocessor on
the compilation and redirect to the file, then you can see the list of
include files when you are compiling your program.


HTH
Rahul
 
N

Niklas Norrthon

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 timespec tmsp' has incomplete type and
cannot b
e initialized


The Source realted to it is

bool Socket :: hangOnConnection (int nNanoSecond)
{
struct timespec tmsp;
/*tmsp.tv_sec = (time_t) 0;
if (nNanoSecond) tmsp.tv_nsec = nNanoSecond;
else tmsp.tv_nsec = 110;
if (nanosleep (&tmsp, NULL) < 0)
{
DEBUG_MSG ("Error occured during hangOn");
return false;
}*/
return true;
}

Here are the error messages I get:

cpp.c:1: error: syntax error before "Socket"
cpp.c:2: warning: return type defaults to `int'
cpp.c: In function `hangOnConnection':
cpp.c:3: error: storage size of 'tmsp' isn't known
cpp.c:12: error: `true' undeclared (first use in this function)
cpp.c:12: error: (Each undeclared identifier is reported only once
cpp.c:12: error: for each function it appears in.)
cpp.c:3: warning: unused variable `tmsp'
cpp.c: At top level:
cpp.c:1: warning: unused parameter 'nNanoSecond'

I suggest that you either fix the syntax errors and repost, or
post to a group where the code above is syntactically correct.
(comp.lang.c++ comes to mind).
"struct timespec" is defined in <sys/types.h>

Neither C or C++ has such a header.

/Niklas Norrthon
 
A

abdur_rab7

Hi Keith Thompson,

Here is the sample programm in C

#include <stdio.h>
#include <sys/types.h>
#include <time.h>

int hangOn (int nNanoSecond)
{
struct timespec tmsp;
/*tmsp.tv_sec = (time_t) 0;
if (nNanoSecond) tmsp.tv_nsec = nNanoSecond;
else tmsp.tv_nsec = 110;
if (nanosleep (&tmsp, NULL) < 0) return -1;
*/
return (0);

}


int main ()
{
printf ("\n The function hangOn is being called\n");
printf ("\n The Return Value is : %d\n", hangOn (110));
return (0);
}

I get two different errors when i compile it with 'gcc' as well as
'g++' compiler

gcc compilation
-----------------------
bash-2.02$ gcc -o tes test.c
test.c: In function `hangOn':


g++ compilation
-----------------------test.c:7: storage size of `tmsp' isn't known
bash-2.02$ g++ -o tes test.c
test.c: In function `int hangOn(int)':
test.c:7: aggregate `struct timespec tmsp' has incomplete type and
cannot be ini
tialized
bash-2.02$

the structure defined in <sys/types.h>

The definition part alone
---------------------------------------
#ifndef __time_t_defined
typedef _TIME_T_ time_t;
#define __time_t_defined

/* Time Value Specification Structures, P1003.1b-1993, p. 261 */

struct timespec {
time_t tv_sec; /* Seconds */
long tv_nsec; /* Nanoseconds */
};

struct itimerspec {
struct timespec it_interval; /* Timer period */
struct timespec it_value; /* Timer expiration */
};
#endif

If there is some patch for cygwin, please let me know about it

Best Regards,
Abdur
 
R

Richard Bos

Hi Keith Thompson,

This is a newsgroup, not a personal conversation.
Here is the sample programm in C

_The_ sample program? A sample program of what, exactly? Learn to quote
context, man! Google Beta's brokenness is no excuse for you to be just
as broken.
#include <stdio.h>
#include <sys/types.h>

This is not C...
#include <time.h>

int hangOn (int nNanoSecond)
{
struct timespec tmsp;

....nor is this...
/*tmsp.tv_sec = (time_t) 0;
if (nNanoSecond) tmsp.tv_nsec = nNanoSecond;
else tmsp.tv_nsec = 110;

....or either of these...
if (nanosleep (&tmsp, NULL) < 0) return -1;

....or this.
*/
return (0);

}


int main ()
{
printf ("\n The function hangOn is being called\n");
printf ("\n The Return Value is : %d\n", hangOn (110));
return (0);
}

I get two different errors when i compile it with 'gcc' as well as
'g++' compiler

gcc compilation

That's not the whole error message. Besides, with that command line,
you're not compiling C, but Ganuck. Your problem seems to be with the
Gnu extensions; you'll need to ask about those in a gcc newsgroup.
They're off-topic here.
the structure defined in <sys/types.h>

_Now_ he tells us.
The definition part alone
---------------------------------------
#ifndef __time_t_defined
typedef _TIME_T_ time_t;
#define __time_t_defined

/* Time Value Specification Structures, P1003.1b-1993, p. 261 */

struct timespec {
time_t tv_sec; /* Seconds */
long tv_nsec; /* Nanoseconds */
};

struct itimerspec {
struct timespec it_interval; /* Timer period */
struct timespec it_value; /* Timer expiration */
};
#endif

Note that all of this
- only defines the structs, and doesn't declare the nanosleep()
function, let alone explain its use;
- does not agree with the error message you posted, for the code you
If there is some patch for cygwin,

....it is on-topic in a cygwin newsgroup. Or possibly a gcc newsgroup;
please have the decency to check what is on-topic there before posting,
unlike your behaviour here.

Richard
 
A

abdur_rab7

Thanks Richard
_The_ sample program? A sample program of what, exactly? Learn to quote
context, man! Google Beta's brokenness is no excuse for you to be just
as broken.

May be you are good in giving context......
the structure defined in <sys/types.h>
_Now_ he tells us.


May be u did not see the earlier loop
"struct timespec" is defined in <sys/types.h>
"No it isn't. There is no such header file defined in ISO standard
C. What you have here is neither C nor topical. Get thee to a
newsgroupery dealing with your language and/or system. When you
find such post compilable code via cut and paste, not retyping."

You can help me out rather than pointing out mistakes.

Abdur
 
A

abdur_rab7

Posting it again as per request

#include <stdio.h>
#include <sys/types.h>
#include <time.h>
int hangOn (int nNanoSecond)
{
struct timespec tmsp;
/*tmsp.tv_sec = (time_t) 0;
if (nNanoSecond) tmsp.tv_nsec = nNanoSecond;
else tmsp.tv_nsec = 110;
if (nanosleep (&tmsp, NULL) < 0) return -1;
*/
return (0);


}

int main ()
{
printf ("\n The function hangOn is being called\n");
printf ("\n The Return Value is : %d\n", hangOn (110));
return (0);


}
 
C

Chuck F.

Rahul said:
Normally in Solaris compiler (workshop 6 update 2) the
defination of struct timespec is present in sys/time_impl.h, But
you don't have to include this file directly.

Instead of that please include <time.h> this wiill include
time_impl.h implicitly.

Wrong again. time.h connects to the facility, but you have no idea
how. Your system is not canonical.
If you wish to debug the error, then please run the c
preprocessor on the compilation and redirect to the file, then
you can see the list of include files when you are compiling
your program.

From this viewpoint it appears that Indian users of google are
especially dense or uncooperative. They seem to persist in failing
to quote properly, even after being given repeated instructions in
how to do so. They also have a nasty tendency to use childish
abbreviations (not the above user). Is this some sort of cultural
failing or what?

It is possible that I am mistaken, since the Indian names are
fairly obvious to classify, and the names of other misusers of
usenet tend to be more varied.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
 
C

Chuck F.

.... snip ...

You can help me out rather than pointing out mistakes.

If you correct the silly, careless, and rude mistakes you might be
able to communicate over Usenet.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
 
R

Richard Bos

Thanks Richard

context, man! Google Beta's brokenness is no excuse for you to be just
as broken.

May be you are good in giving context......

That sentence makes no sense. Search this group for references to Google
- context - quoting. I believe Chuck F. has a useful link in his .sig.
May be u did not see the earlier loop

Again, non sequitur. There was no loop in your post. There is no loop in
this entire thread. What are you talking about, man?
"No it isn't. There is no such header file defined in ISO standard
C. What you have here is neither C nor topical. Get thee to a
newsgroupery dealing with your language and/or system. When you
find such post compilable code via cut and paste, not retyping."

I did not write this. Chuck F. did. Do not quote it (however brokenly)
as if I did.
You can help me out rather than pointing out mistakes.

You can let yourself be helped rather than resisting decent netizenship.
Your question is off-topic here; what you wrote is POSIX-extended (or
possibly Gnu) C, not ISO C, and it appears (though you hardly have given
sufficient material to nail it down solidly) that the problem is in the
POSIX bits.

Richard
 
K

Keith Thompson

Hi Keith Thompson,

Why are you addressing me personally? This is a newgroup, not e-mail.

I will ask you again to read <http://cfaj.freeshell.org/google/>.
Please please please don't post to Usenet again until you read this
web page and follow its advice.
Here is the sample programm in C

#include <stdio.h>
#include <sys/types.h>
#include <time.h>

Again, <sys/types.h> is not a standard C header. (It's probably
defined by POSIX, but not by ISO C.) It is therefore off-topic in
this newsgroup.
int hangOn (int nNanoSecond)
{
struct timespec tmsp;
/*tmsp.tv_sec = (time_t) 0;
if (nNanoSecond) tmsp.tv_nsec = nNanoSecond;
else tmsp.tv_nsec = 110;
if (nanosleep (&tmsp, NULL) < 0) return -1;
*/
return (0);

}

Several lines of this function are commented out. I suggest deleting
them before you post your code; they're only causing confusion.
int main ()
{
printf ("\n The function hangOn is being called\n");
printf ("\n The Return Value is : %d\n", hangOn (110));
return (0);
}

I get two different errors when i compile it with 'gcc' as well as
'g++' compiler

gcc compilation

If you don't show us the actual error message, we can't help you.
g++ compilation
[snip]

g++ is a C++ compiler. We don't care what it does. If you have
questions about C++, post to comp.lang.c++.

<OFF-TOPIC>
I compiled your code under Cygwin, and got no error messages. I don't
know what your problem is. Perhaps you need to upgrade your system.
(Cygwin makes this easy to do, using the same mechanism you used to
install it in the first place.)
</OFF-TOPIC>

If you can reproduce the problem with a *portable* C program that
doesn't depend on any non-standard headers, we may be able to help
you. Try incorporating the relevant declarations from <sys/types.h>
into your program, and dropping the "#include <sys/types.h>". Or post
to a Cygwin mailing list; see the Cygwin web site for details.
 
S

santosh

Chuck said:
From this viewpoint it appears that Indian users of google are
especially dense or uncooperative. They seem to persist in failing
to quote properly, even after being given repeated instructions in
how to do so. They also have a nasty tendency to use childish
abbreviations (not the above user). Is this some sort of cultural
failing or what?

<OT>
More like *lack* of culture with regard to computers. Computers and
USENET existed *much* before they were even remotely known in India,
(indeed this applies to other developing countries too).

Since most of these guys tend to spend a lot of time using Chat and
Instant Messaging, they just don't get the concept behind attribution.
In addition when they see the 'Tree' view offered in Google Groups they
don't see why they should take the pain to include blocks of text.

There is no love of science or technology for it's sake. For the vast
majority here it's a means of minting bucks rendering "boot polishing"
to the west.
It is possible that I am mistaken, since the Indian names are
fairly obvious to classify, and the names of other misusers of
usenet tend to be more varied.

I hang around in alt.lang.asm and I have noticed many Italians, East
Europeans and others also failing to uphold correct USENET etiquette.
It seems to be rather common among most people who are not from
W.Europe, USA, Australia or Russia. Those cultures which have not
actively developed these technologies but instead simply adopt them
don't seem to display the highest standards of Netiquette.
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>

This won't work with people who only know the language of time and
money. It's hopeless to introduce "globalisation" and remain such a
prude as well. Six billion elephants can all be expected to be white.

</OT>
 
A

abdur_rab7

Thank you all, there was a problem with my cygwin installation.
Installed the patch and able to compile it without any problem.

Thank you for your valuable comments; it helped me a lot for nailing
down to the exact problem.
From this viewpoint it appears that Indian users of google are
especially dense or uncooperative. They seem to persist in failing
to quote properly, even after being given repeated instructions in
how to do so. They also have a nasty tendency to use childish
abbreviations (not the above user). Is this some sort of cultural
failing or what?

May be it was my fault. Please do not blame the total Indian population
for that

Wish u all a Happy and Prosperous New Year

Best Regards,
Abdur
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top