Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / May 2006



Tip: Looking for answers? Try searching our database.

no chdir() in mach-o build of CW9?!?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ultimatewarrior - 08 May 2006 10:40 GMT
Hi all,
I've a little problem with CW9: if i start a mach-o standard C
project, there seems to be no chdir() function!!! The function is
defined and implemented in classic and carbon libraries, but it's no
more present in the mach-o ones! Is there a workaround for it? Is there
a way to change the current working directory with some CF
object/function?... I need to change the working dir to the one that
contains the application, so that I can use fopen() with relative
paths...

Thanx in advance to everyone so kind to answer me!...
David Phillip Oster - 08 May 2006 15:00 GMT
>  I've a little problem with CW9: if i start a mach-o standard C
> project, there seems to be no chdir() function!!! The function is
[quoted text clipped - 4 lines]
> contains the application, so that I can use fopen() with relative
> paths...

Have you dragged /System/Library/Frameworks/System.framework from the
Finder to the Frameworks tab?

Have you added the line:

#include <unistd.h>

to include the appropriate header file?
ultimatewarrior - 08 May 2006 15:49 GMT
yes, I did of course, but the problem is that chdir() is not even
defined in unistd.h! There are some conditional macros that define it
only for classic or carbon builds, but not for mach-o! And in the
standard project libraries, there is no implementation for chdir() in
the MSL All Mach-o, only for the standard fopen(), fclose() etc... :(
David Phillip Oster - 09 May 2006 02:20 GMT
> yes, I did of course, but the problem is that chdir() is not even
> defined in unistd.h! There are some conditional macros that define it
> only for classic or carbon builds, but not for mach-o! And in the
> standard project libraries, there is no implementation for chdir() in
> the MSL All Mach-o, only for the standard fopen(), fclose() etc... :(

You are looking in the wrong one. /usr/include/unistd.h has no such
problem. Check your access paths.
ultimatewarrior - 09 May 2006 08:51 GMT
Ok, but how can I get to /usr/include/unistd.h? CW9 in a standard C
Mach-o stationery project places its access paths (MSL, MacOS X Support
etc.) BEFORE usr/include, so if I #include unistd.h I get MW's one, not
/usr/include/unistd.h - and if I change the order of the access paths
so that unix ones are before MW's, I get an error from CW9 complaining
about the fact that its access paths are after unix ones! And, anyway,
the problem remains, because even if I can get the definition of
chdir(), still I can't find the implementation...
David Phillip Oster - 09 May 2006 15:02 GMT
> Ok, but how can I get to /usr/include/unistd.h? CW9 in a standard C
> Mach-o stationery project places its access paths (MSL, MacOS X Support
[quoted text clipped - 4 lines]
> the problem remains, because even if I can get the definition of
> chdir(), still I can't find the implementation...

I just tried it, and could not reproduce your problem.

I used CW9 to create a "C Toolbox Mach-o" variant of a standard C Mach-o
stationery project. I didn't need to touch the access paths. I didn't
need to add any frameworks.

The program:
#include <Carbon/Carbon.h>
#include <unistd.h>

int main(void){
  InitCursor();
  chdir("/");
  return 0;
}

compiled and linked with no problems. Option clicking on the call the
chdir showed that it was declared in the correct unistd.h

One difference between you and me:
Using the "Preferences" menu command, under the Codewarrior menu, in the
Source Trees panel, I'd added the line:

Name          Path
OS X Volume   /Developer/SDKs/MacOSX10.3.9.sdk

And of course I do have that SDK installed from Xcode.

I hope this helps.
ultimatewarrior - 09 May 2006 17:20 GMT
SOLVED!

Thank you for your aid, but I solved the problem in a really
"quick-and-dirt" way by simply declaring the chdir() prototype as it
appears in the unix unistd.h file. It worked. I dunno why I still
cannot get to the unistd.h file in usr/include, however the workaround
is just ok for my needs...

Thanx very much for your help!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.