473,473 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Create 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::doGameMenu()':
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(filehandle,&fileinfo);
skinCount++;

while((-1L != nRes) && (skinCount < 7))
{
strcpy(skinList[skinCount],fileinfo.name);
skinCount++;
nRes = _findnext(filehandle,&fileinfo);
}
}
subMenuOption = selectMenu(skinCount,skinList,skinListHelp,subMenu Pos);

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

// Select skin
if(subMenuOption > -1)

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

// Show skin preview
strcpy(tempSkinName,skinName);
strcpy(skinName,skinList[subMenuPos]);
BS_DELETE(wndSkinPreview);
wndSkinPreview = new UGameWindow;

wndSkinPreview->Create(800,400,400,200,RenderDevice,createSkinPat h("skin_preview.tga"),1.0f);
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,"Mods/%s",fileinfo.name);

f = fopen(path,"rt");
fgets(modList[modCount],256,f);
fgets(modListFolder[modCount],256,f);
fgets(modListHelp[modCount],256,f);
fclose(f);
modCount++;

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

while(( -1L != nRes) && (modCount < 7))
{
sprintf(path,"Mods/%s",fileinfo.name);
f = fopen(path,"rt");
fgets(modList[modCount],256,f);
fgets(modListFolder[modCount],256,f);
fgets(modListHelp[modCount],256,f);
fclose(f);
modCount++;

nRes = _findnext(filehandle,&fileinfo);
}
}


subMenuOption = selectMenu(modCount,modList,modListHelp,subMenuPos );
// ESC pressed
if(subMenuOption == -2)
{
subMenuOption = -1;
menuOption = -1;
subMenuPos = 0;
}

// Enter pressed, selecting mod
if(subMenuOption > -1)
{
// The mod folder name end with a \n
// we must clear this
modListFolder[subMenuOption][strlen(modListFolder[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(createGamePath("LevelList.txt"),"rt");
fscanf(pFile,"%d",&levelCount);

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

GameLog.printf("\nBSUCEngine :: Loading modification [%s] with [%d]
levels.",modList[subMenuOption],levelCount);

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

}

line 831 for(i = 0; i < 7; i++)
Jul 23 '05 #1
4 3227
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::doGameMenu()':
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(filehandle,&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(filehandle,&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(dirSkin);

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(dirSkin);


I have 'dirent fileinfo = *readdir(dirSkin);' 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(filehandle,&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...stupid 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
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...
14
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...
1
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,...
5
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
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...
15
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...
1
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...
9
by: Aditi | last post by:
I am working around a problem called Y2038 bug....
0
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...
0
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
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: 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...
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.

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.