public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: Probably a very simple problem - hopefully someone will help me
@ 2001-07-23 14:45 Heribert Dahms
  2001-07-23 17:07 ` Kurt Roeckx
  0 siblings, 1 reply; 5+ messages in thread
From: Heribert Dahms @ 2001-07-23 14:45 UTC (permalink / raw)
  To: 'Kurt Roeckx'; +Cc: cygwin

Hi Kurt,

almost! According to Appendix A of Richard W. Steven's famous
"Advanced Programming in the UNIX Environment" (a "must have" IMHO)
lseek needs including <sys/types.h> before <unistd.h>!

Bye, Heribert (heribert_dahms@icon-gmbh.de)

> -----Original Message-----
> From:	Kurt Roeckx [SMTP:Q@ping.be]
> Sent:	Monday, July 23, 2001 17:23
> To:	cygwin@cygwin.com
> Cc:	cygwin@cygwin.com
> Subject:	Re: Probably a very simple problem - hopefully someone will
> help me
> 
> On Sun, Jul 22, 2001 at 09:51:07PM +0100, David Ayliffe wrote:
> > 
> > I get these errors when I compile using the command directly below
> > 
> > $ gcc byte_hacking.cpp
> > byte_hacking.cpp: In function 'int main():
> > byte_hacking.cpp:20 implicit declaration of function 'int lseek(...)'
> > byte_hacking.cpp:22 implicit declaration of function 'int read(...)'
> > byte_hacking.cpp:27 implicit declaration of function 'int write(...)'
> > byte_hacking.cpp:25 implicit declaration of function 'int close(...)'
> 
> They're not errors, they're warnings.
> 
> > //Gets records from a MS Access Database
> > 
> > #include <io.h>
> > #include <fcntl.h>
> > #include <stdio.h>
> > #include <sys\stat.h>
> 
> It should be <sys/stat.h>, and you forgot: #include <unistd.h>
> which declares all of those functions.
> 
> 
> Kurt
> 
> 
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread
* Probably a very simple problem - hopefully someone will help me
@ 2001-07-22 13:53 David Ayliffe
  2001-07-22 14:04 ` edward
  2001-07-23  8:23 ` Kurt Roeckx
  0 siblings, 2 replies; 5+ messages in thread
From: David Ayliffe @ 2001-07-22 13:53 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 2107 bytes --]

Hello and thanks for your time.
I have been subscribed to this list now for 1824 posts but this is my
first post.
I have a file (attached) which I can't compile under cygwin using gcc.
Is it possible for this file to be compiled using cygwin, and if so can
you point me to where I am going wrong?  Sorry if this is a REALLY dolly
question but we all start somewhere.  PS This code compiles fine under
VC6.

I get these errors when I compile using the command directly below

$ gcc byte_hacking.cpp
byte_hacking.cpp: In function 'int main():
byte_hacking.cpp:20 implicit declaration of function 'int lseek(...)'
byte_hacking.cpp:22 implicit declaration of function 'int read(...)'
byte_hacking.cpp:27 implicit declaration of function 'int write(...)'
byte_hacking.cpp:25 implicit declaration of function 'int close(...)'

Thanks lots
David Ayliffe (mail@ayliffe.com)

Running Windows 2000 Advanced Server (SP2) with Cygwin gcc 2.95.3-5
Also running Suse Linux 7.1 Professional kernel 2.4








<ATTATCHED CODE FOR THOSE WHO CANT BE BOTHERED TO OPEN THE ATTACHMENT>
//Gets records from a MS Access Database

#include <io.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys\stat.h>

//#define database = northwind.mdb;

int main ()
{
	int f,buf;
	int isuccess = 0;

	printf ("Lists records in database\n");
	printf ("**************************\n\n");
	if (chmod("northwind.mdb",S_IWRITE)!=-1 && (f=open
("northwind.mdb",O_RDWR | O_BINARY))!=-1) 
	{
			 //handle, offest, origin

		if (lseek (f,0,SEEK_SET)!=1) 
		{
			if (read (f,&buf,2)==2 && buf==0x037D) 
			{
				printf ("Reading records");
				lseek (f,346345,SEEK_SET);
				buf=0x9090; //nop nop
				if (write(f,&buf,2)==2)  
				{	
					printf ("Success.");
				}
				else 
				{
					printf ("Failed due to unknown
reason.");
				}
			} 
			else 
			{			
				printf("Cannot find start location.
File may not be .mdb file");
			}
		} 
		else 
		{
			printf("Seek error.");
		}
		close(f);
    } 
	else 
	{
		printf ("Cannot find northwind.mdb");
	}
	return isuccess;
}

<END OF ATTATCHED CODE FOR THOSE WHO CANT BE BOTHERED TO OPEN THE
ATTACHMENT>

[-- Attachment #2: byte_hacking.cpp --]
[-- Type: text/x-c, Size: 964 bytes --]

//Gets records from a MS Access Database

#include <io.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys\stat.h>

#define database = northwind.mdb;

int main ()
{
	int f,buf;
	int isuccess = 0;

	printf ("Lists records in database\n");
	printf ("**************************\n\n");
	if (chmod("northwind.mdb",S_IWRITE)!=-1 && (f=open ("northwind.mdb",O_RDWR | O_BINARY))!=-1) 
	{
			 //handle, offest, origin				
		if (lseek (f,0,SEEK_SET)!=1) 
		{
			if (read (f,&buf,2)==2 && buf==0x037D) 
			{
				printf ("Reading records");
				lseek (f,346345,SEEK_SET);
				buf=0x9090; //nop nop
				if (write(f,&buf,2)==2)  
				{	
					printf ("Success.");
				}
				else 
				{
					printf ("Failed due to unknown reason.");
				}
			} 
			else 
			{			
				printf("Cannot find start location.  File may not be .mdb file");
			}
		} 
		else 
		{
			printf("Seek error.");
		}
		close(f);
    } 
	else 
	{
		printf ("Cannot find northwind.mdb");
	}
	return isuccess;
}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-07-23 17:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-23 14:45 Probably a very simple problem - hopefully someone will help me Heribert Dahms
2001-07-23 17:07 ` Kurt Roeckx
  -- strict thread matches above, loose matches on Subject: below --
2001-07-22 13:53 David Ayliffe
2001-07-22 14:04 ` edward
2001-07-23  8:23 ` Kurt Roeckx

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).