473,748 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

linux c++ equivalent

Jon
For the past month I have been porting a DirectX windows game to libSDL
on linux, for right now I am working on the basic syntax of the game
engine, I was having problems with opening, reading, and closeing of
directories, I have fixed that though...who woulda thought that it would
be open, read, and closedir()?

Anyway, I am still working on the syntax, and I have been getting these
errors when I compile:

UEngine.cpp: In member function `void UEngine::doGame Menu()':
UEngine.cpp:677 : error: `fileinfo' undeclared (first use this function)
UEngine.cpp:677 : error: (Each undeclared identifier is reported only
once for
each function it appears in.)
UEngine.cpp:678 : error: `_findnext' undeclared (first use this function)
UEngine.cpp:743 : error: aggregate `_finddata_t fileinfo' has incomplete type
and cannot be defined
UEngine.cpp:748 : error: `_findfirst' undeclared (first use this function)
UEngine.cpp:830 : error: name lookup of `i' changed for new ISO `for' scoping
UEngine.cpp:735 : error: using obsolete binding at `i'

I would post the engine code but it's nearly 1000 lines of code, but
here are snippets:

// Go throug the /Skin directory and look for skins
int modCount = 0;
DIR *opendir(const char *Skin);
long filehandle = -1L;
int nRes;

skinCount = 0;

struct dirent *readdir(DIR *Skin);

if(filehandle == -1L)
{
menuOption = -1;

}
else
{
line 677 strcpy(skinList[skinCount],fileinfo.name) ;
line 678 nRes = _findnext(fileh andle,&fileinfo );
skinCount++;

while((-1L != nRes) && (skinCount < 7))
{
strcpy(skinList[skinCount],fileinfo.name) ;
skinCount++;
nRes = _findnext(fileh andle,&fileinfo );
}
}
subMenuOption = selectMenu(skin Count,skinList, skinListHelp,su bMenuPos);

// ESC pressed
if(subMenuOptio n == -2)
menuOption = -1;

// Select skin
if(subMenuOptio n > -1)

{
strcpy(skinName ,skinList[subMenuOption]);
menuOption = -1;
subMenuOption = -1;
subMenuPos = 0;
}

// Show skin preview
strcpy(tempSkin Name,skinName);
strcpy(skinName ,skinList[subMenuPos]);
BS_DELETE(wndSk inPreview);
wndSkinPreview = new UGameWindow;

wndSkinPreview->Create(800,400 ,400,200,Render Device,createSk inPath("skin_pr eview.tga"),1.0 f);
strcpy(skinName ,tempSkinName);

for(i = 0; i < skinCount; i++)
{
delete skinList[i];
delete skinListHelp[i];
}
}
int closedir(DIR *Skin);
............... ...........
line 735 for(int i = 0; i < 7; i++)
{
modList[i] = new char[256];
modListFolder[i] = new char[256];
modListHelp[i] = new char[256];
}

int modCount = 0;
DIR *opendir(const char *Mods);
long filehandle = -1L;
int nRes;
struct dirent *readdir(DIR *Mods);

// Ignore the menu if there are no MODS installed
if(filehandle == -1L)
{
subMenuOption = -1;
menuOption = -1;
subMenuPos = 0;
}
else
{
// Read in first mod
FILE* f;
char path[256];
sprintf(path,"M ods/%s",fileinfo.na me);

f = fopen(path,"rt" );
fgets(modList[modCount],256,f);
fgets(modListFo lder[modCount],256,f);
fgets(modListHe lp[modCount],256,f);
fclose(f);
modCount++;

// Scan for next modes
nRes = _findnext(fileh andle,&fileinfo );

while(( -1L != nRes) && (modCount < 7))
{
sprintf(path,"M ods/%s",fileinfo.na me);
f = fopen(path,"rt" );
fgets(modList[modCount],256,f);
fgets(modListFo lder[modCount],256,f);
fgets(modListHe lp[modCount],256,f);
fclose(f);
modCount++;

nRes = _findnext(fileh andle,&fileinfo );
}
}


subMenuOption = selectMenu(modC ount,modList,mo dListHelp,subMe nuPos);
// ESC pressed
if(subMenuOptio n == -2)
{
subMenuOption = -1;
menuOption = -1;
subMenuPos = 0;
}

// Enter pressed, selecting mod
if(subMenuOptio n > -1)
{
// The mod folder name end with a \n
// we must clear this
modListFolder[subMenuOption][strlen(modListF older[subMenuOption]) -
1] = 0;
// Set current mod to selected mod
strcpy(modName, modListFolder[subMenuOption]);

menuOption = -1;

// Reload the list with the game levels
FILE* pFile = fopen(createGam ePath("LevelLis t.txt"),"rt");
fscanf(pFile,"% d",&levelCount) ;

for(int i = 0; i < this->levelCount;i++ )
{
this->levelNameLis t[i] = new char[256];
fscanf(pFile,"% s\n",levelNameL ist[i]);
}

GameLog.printf( "\nBSUCEngi ne :: Loading modification [%s] with [%d]
levels.",modLis t[subMenuOption],levelCount);

subMenuOption = -1;
subMenuPos = -1;
subMenuPos = 0;

}

line 831 for(i = 0; i < 7; i++)
Jul 23 '05 #1
4 3247
Jon wrote:
For the past month I have been porting a DirectX windows game to libSDL
on linux, for right now I am working on the basic syntax of the game
engine, I was having problems with opening, reading, and closeing of
directories, I have fixed that though...who woulda thought that it would
be open, read, and closedir()?

Anyway, I am still working on the syntax, and I have been getting these
errors when I compile:

UEngine.cpp: In member function `void UEngine::doGame Menu()':
UEngine.cpp:677 : error: `fileinfo' undeclared (first use this function)
UEngine.cpp:677 : error: (Each undeclared identifier is reported only
once for
each function it appears in.)
UEngine.cpp:678 : error: `_findnext' undeclared (first use this function)
UEngine.cpp:743 : error: aggregate `_finddata_t fileinfo' has incomplete
type
and cannot be defined
UEngine.cpp:748 : error: `_findfirst' undeclared (first use this function)
UEngine.cpp:830 : error: name lookup of `i' changed for new ISO `for'
scoping
UEngine.cpp:735 : error: using obsolete binding at `i'

I would post the engine code but it's nearly 1000 lines of code, but
here are snippets:

// Go throug the /Skin directory and look for skins
int modCount = 0;
DIR *opendir(const char *Skin);
The line above is a declaration. Did you mean to call 'opendir'
function?
long filehandle = -1L;
int nRes;

skinCount = 0;

struct dirent *readdir(DIR *Skin);
The line above is a declaration. Did you mean to call 'readdir'
function?

if(filehandle == -1L)
{
menuOption = -1;

}
else
{
line 677 strcpy(skinList[skinCount],fileinfo.name) ;
'fileinfo' is not declared or not an object. Did you mean to define
'fileinfo' at the same like where you [try to] call 'readdir'?
line 678 nRes = _findnext(fileh andle,&fileinfo );
Same thing. 'fileinfo' is not declared.
skinCount++;
[...]
line 831 for(i = 0; i < 7; i++)


for (int i = 0; i < 7; i++)

V
Jul 23 '05 #2
Jon
Victor Bazarov wrote:
// Go throug the /Skin directory and look for skins
int modCount = 0;
DIR *opendir(const char *Skin);

The line above is a declaration. Did you mean to call 'opendir'
function?

Yes I did, and I assume that it should be "DIR opendir(const char
*Skin);" instead of "DIR *opendir(const char *Skin);"
long filehandle = -1L;
int nRes;

skinCount = 0;

struct dirent *readdir(DIR *Skin);

The line above is a declaration. Did you mean to call 'readdir'
function?


Again yes I did, and I assume that I should do the same thing as above
"struct dirent readdir(DIR *Skin);"

if(filehandle == -1L)
{
menuOption = -1;

}
else
{
line 677 strcpy(skinList[skinCount],fileinfo.name) ;

'fileinfo' is not declared or not an object. Did you mean to define
'fileinfo' at the same like where you [try to] call 'readdir'?


I guess I want to define 'fileinfo', not 100% sure as I am still
learning c++
line 678 nRes = _findnext(fileh andle,&fileinfo );

Same thing. 'fileinfo' is not declared.


Also the same as above.
skinCount++;

[...]

line 831 for(i = 0; i < 7; i++)

for (int i = 0; i < 7; i++)

V


Not entirely sure what the 'V' us for, but the 'int' fixed the error I
was getting.
--
Suicide is man's way of telling god ...I quit
Jul 23 '05 #3
Jon wrote:
Victor Bazarov wrote:
// Go throug the /Skin directory and look for skins
int modCount = 0;
DIR *opendir(const char *Skin);
The line above is a declaration. Did you mean to call 'opendir'
function?


Yes I did, and I assume that it should be "DIR opendir(const char
*Skin);" instead of "DIR *opendir(const char *Skin);"


No.

How should I put this?... Do you know C++? At all? Perhaps you should
find a decent book or something... I hate to break it to you like this,
but you seem to be really not ready for this porting effort.

OK, for the sake of experiment... The line should read

DIR *dirSkin = opendir(Skin); // assuming 'Skin' is a const char*.
long filehandle = -1L;
int nRes;

skinCount = 0;

struct dirent *readdir(DIR *Skin);


The line above is a declaration. Did you mean to call 'readdir'
function?

Again yes I did, and I assume that I should do the same thing as above
"struct dirent readdir(DIR *Skin);"


Again, no. It might be something like

dirent fileinfo = *readdir(dirSki n);

maybe.
[...]

line 831 for(i = 0; i < 7; i++)


for (int i = 0; i < 7; i++)

V

Not entirely sure what the 'V' us for, but the 'int' fixed the error I
was getting.


'V' is the initial of my first name. I am too lazy to write 'Victor'
every time, given that I have this rather stupid habit of signing my
posts.

V
Jul 23 '05 #4
Jon
Victor Bazarov wrote:
Jon wrote:
Victor Bazarov wrote:
// Go throug the /Skin directory and look for skins
int modCount = 0;
DIR *opendir(const char *Skin);


The line above is a declaration. Did you mean to call 'opendir'
function?

Yes I did, and I assume that it should be "DIR opendir(const char
*Skin);" instead of "DIR *opendir(const char *Skin);"

No.

How should I put this?... Do you know C++? At all? Perhaps you should
find a decent book or something... I hate to break it to you like this,
but you seem to be really not ready for this porting effort.

OK, for the sake of experiment... The line should read

DIR *dirSkin = opendir(Skin); // assuming 'Skin' is a const char*.


ok, I got that snippet working with the code. (after seeing one of the
stupidst mistakes ever)

I now have this code:

// Go through the /Skin directory and look for skins
int modCount = 0;
const char *Skin;
DIR *dirSkin = opendir(Skin); // assuming 'Skin' is a const char*
long filehandle = -1L;
int nRes;

I have no errors at this part of code...although one thing I don't under
stand, I have mode 'DIR opendir(const char *Skin);' statements in other
parts of the engine, how come I don't receive an error? (I also didn't
receive an error when I compiled before I changed it to 'DIR
*opendir(const char *Skin);'?
long filehandle = -1L;
int nRes;

skinCount = 0;

struct dirent *readdir(DIR *Skin);


The line above is a declaration. Did you mean to call 'readdir'
function?


Again yes I did, and I assume that I should do the same thing as above
"struct dirent readdir(DIR *Skin);"

Again, no. It might be something like

dirent fileinfo = *readdir(dirSki n);


I have 'dirent fileinfo = *readdir(dirSki n);' in the code, and I now get
the error:

UEngine.cpp:678 : error: 'struct dirent' has no member named 'name'

here is a code snippet from around that line:

strcpy(skinList[skinCount],fileinfo.name) ;
nRes = _findnext(fileh andle,&fileinfo );
skinCount++;

I'm guessing that the '....' has no member named 'name' is the
'fileinfo.name' in '
strcpy(skinList[skinCount],fileinfo.name) ;'

I'm not really sure how to fix this....too much of a newbie to c++ :(
[...]

line 831 for(i = 0; i < 7; i++)


for (int i = 0; i < 7; i++)

V


Not entirely sure what the 'V' us for, but the 'int' fixed the error I
was getting.

'V' is the initial of my first name. I am too lazy to write 'Victor'
every time, given that I have this rather stupid habit of signing my
posts.

V


I guess I should have figured that...for some stupid reason I thought it
was part of the code snippet...stupi d me :(
As a note to your comment

"How should I put this?... Do you know C++? At all? Perhaps you should find a decent book or something... I hate to break it to you like this,
but you seem to be really not ready for this porting effort."


You are right I really am *not* ready for porting, nor do I know much
C++, but I like challanges, it's how I learn, if I read a book, or
tutorial, I don't learn anything, unless I look at the code of programs.
--
Suicide is man's way of telling god ...I quit
Jul 23 '05 #5

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

Similar topics

14
2215
by: Ranger West | last post by:
Hello there, Are there any out-of-the box handhelds that run Linux/Apache/MYSQL and PHP? Does Redhat, Suse, or Gentoo support any handhelds? I know the Zaurus comes close, but I've heard people have problems running LAMP applications on it. It would be cool to be able to run any LAMP application on sourceforge on a handheld computer.
14
7308
by: John | last post by:
Is there an equivalent of COM on Linux that I can get through Python. My need is to have some sort of language independent component framework. I can think of CORBA but I have to have a server running. I prefer not to. I just need Python components for local consumption in other languages. I remember Gnome libs having some thing like this. Any thoughts?
1
1842
by: harshaL | last post by:
Guys, Actually i want to implement Doors on Linux using C++ coding, on threads, thing is following Interfaces door_bind, door_call, door_create, door_cred, door_info, door_return, door_revoke,
5
4577
by: aman | last post by:
I need to implement getche() but as I am working on Linux and that I cant use conio.h, is there any equivalent???
3
5736
by: Bruno LIVERNAIS | last post by:
Hi, We are currently installing a DB2 V9 ESE on a Linux server (RHEL4U4-x86_64). Installation runs successfully on each node. Database user environment is OK and the instance is well created. To be sure, we've started the database with db2start =successfull. And then shut it down again successfully too. The tricks appears when we switch the hp MC/ServiceGuard (A.11.16 for Linux) package to the other node... the database does not want...
15
2870
by: Konstantin Andreev | last post by:
I'm almost sure I've found bad bug, but for a while I can't neither confirm nor reject this. If anybody could make an independent test on it's own system, I'd appreciate it very much. The possible bug is: **************** *** DB2 refuses DEVICE containers bigger than 4Gb. *** ****************
1
6504
by: neelz | last post by:
Hi Friends, I am porting an application from Linux to Windows. In the source code, <sys/times.h>, time.h etc. header files are included and tms structure, times() function are getting used. I have searched a lot and to my knowledge, I came to the conclusion that GetProcessTime() is the equivalent function in Windows that we can use for Linux times() function. Also, I have researched and concluded that FILETIME is the structure that we can use...
9
7240
by: Aditi | last post by:
I am working around a problem called Y2038 bug. http://groups.google.co.in/group/comp.unix.programmer/browse_thread/thread/a2f678e4f2761fb0/2816aaf1f50f863e?hl=en&lnk=st&q=time.h+64+bit+linux#2816aaf1f50f863e I am developing an application which need to be built both on windows and linux and used time_t, ctime, mktime, localtime and gmtime functions from <time.h>. The application already exists and I have to replace these 32bit time...
0
1597
by: c0d3lib | last post by:
I am attempting to implement, what I believe to be, an unusual scenario, and am hoping to find someone that has experience with something similar. I currently have a series of physical and logical files on an iSeries (AS/400, System i5, or whatever IBM calls it today), version v5r4, and would like to permanently migrate them to a DB2 UDB for Linux v8 system. All of these files are used by native iSeries programs (written mostly in CL and...
0
2239
by: tvnaidu | last post by:
I am looking for windows SetTimer equivalent routine in Linux, need to port this line to Linux from Windows. watchdog_timer_id=SetTimer(NULL, 0, 60000, (TIMERPROC)TimerProc);
0
9562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9386
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8255
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6799
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3319
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 we have to send another system

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.