Again C++ question

Andreas Pakulat apaku at gmx.de
Sat Mar 26 17:12:00 GMT 2005


On 26.Mär 2005 - 19:37:47, Muhammad Rizwan wrote:
> I was using kdevelop 2.XX one month ago, and write some code related to
> file handling as:
> 
> 	int fd;
> 	if( (fd = open("file.txt", O_WRONLY | O_CREAT, 0640 ) == -1 )
> 	{
> 		Logging(strerror(errno), 0, ConfigData.Folder);
> 		return(-1);
> 	}
> 	struct flock lockp;
> 	lockp.l_type = F_WRLCK;
> 	lockp.l_whence = SEEK_SET;
> 	lockp.l_start = 0;
> 	lockp.l_len = 0;
> 	if( fcntl (fd, F_SETLK, &lockp) == -1 )
> 	{
> 		Logging(strerror(errno), 0, ConfigData.InsFolder);
> 		close(fd);
> 		return(-1);
> 	}
> 	ofstream outFile(fd);
> 	outFile << "text here";
> 	close(fd);
> 
> I was compiling this program successfully in kdevelop 2.XX, but now i
> have updated my kdevelop version to 3.0 and i am getting errors for file
> descriptors i.e. fd.

What errors specifically? I guess nobody can help you here without the
exact error messages....

> Now which function should i use to open file which 'll return me file
> descriptor, so that i 'll be able to lock file by using fcntl(). Because
> fcntl() accepts file descriptor (i.e. fd) as:

open is a C-functions so you should checkt that you're including the
proper C-header and link against libc...

Andreas

-- 
Never look up when dragons fly overhead.

-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list