Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming

Reply
 
LinkBack Thread Tools
Old 02-22-08   #1 (permalink)
Every base is base 10
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 5,009
Blog Entries: 1

Rep: 566 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 338
FAQs Submitted: 6
Trader Rating: 5
Default C Libraries on OSX

Are the standard C libraries different for OSX? The following bit of code compiles on my school's linux and unix servers, but not my OSX install.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>

#define NAME_MAX 255

int main(int argc, char *argv[]){

  char str_buffer[NAME_MAX];
  char *curr_dir_path;
  DIR *dir;
  struct dirent *entry;

  /* get path and open directory */
  getcwd(str_buffer, NAME_MAX);
  printf("Buffer contents: %sn", str_buffer);
  curr_dir_path = malloc(strlen(str_buffer) * sizeof(char));
  strncpy(curr_dir_path, str_buffer, NAME_MAX);
  printf("dir path: %sn", curr_dir_path);

  dir = opendir(curr_dir_path);

  while(entry = readdir(dir)){
    printf("Entry name: %sn", entry->d_name);
  }

  return 0;

}
Any ideas why?

If it matters the code simply lists all files in the directory its executed from
__________________
BIG BROTHER
Apple doesn't love you

IS WATCHING

System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 02-22-08   #2 (permalink)
Miscelaneous
 
Licht's Avatar
 
amd ati

Join Date: Mar 2007
Location: Bel Air
Posts: 9,933
Blog Entries: 3

Rep: 289 Licht is a proven memberLicht is a proven memberLicht is a proven member
Unique Rep: 188
Folding Team Rank: 904
Trader Rating: 0
Default

Quote:
The following bit of code compiles on my school's linux and unix servers, but not my OSX install.
OSX and Linux are totally different OS from what i have been told even if they are both Unix variants. 1 program on OSX does not run on Linux (usually.) Again, this is what i was told. I have not tested myself.

I do suggest you use Linux over OSX myself however thats merely my opinion, i only mention is since you seam (no offense here if i am wrong) to think they are the same.

System: Uzicht #4
CPU
Athlon X2 5200+ Windsor
Motherboard
Gigabyte 790X AM2+
Memory
6GB Kingston DDR2 667MHZ
Graphics Card
Saphire HD 3870
Hard Drive
4x WD1600AAJS RAID0
Sound Card
X-Fi Extreme Gamer Fatality Professional
Power Supply
OCZ Game-X-Stream 700w
Case
NZXT Black Steel
CPU cooling
Xigmatec Rifle
GPU cooling
Stock Saphire 3870 Cooling
OS
Vista Home Premium x64 SP1
Monitor
Samsung SyncMaster 19"Wide
Licht is online now I fold for Overclock.net Overclocked Account Licht's Gallery   Reply With Quote
Old 02-23-08   #3 (permalink)
Every base is base 10
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 5,009
Blog Entries: 1

Rep: 566 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 338
FAQs Submitted: 6
Trader Rating: 5
Default

Quote:
Originally Posted by Licht View Post
OSX and Linux are totally different OS from what i have been told even if they are both Unix variants. 1 program on OSX does not run on Linux (usually.) Again, this is what i was told. I have not tested myself.

I do suggest you use Linux over OSX myself however thats merely my opinion, i only mention is since you seam (no offense here if i am wrong) to think they are the same.
I know that they are very different, but there's no reason for those functions to behave differently

**EDIT**
I forgot to include the errors . They're string function errors - nothing to do with the filesystem stuff

Code:
gcc test2.c 
test2.c: In function ‘main’:
test2.c:18: warning: incompatible implicit declaration of built-in function ‘strlen’
test2.c:19: warning: incompatible implicit declaration of built-in function ‘strncpy’
__________________
BIG BROTHER
Apple doesn't love you

IS WATCHING

System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw

Last edited by rabidgnome229 : 02-23-08 at 02:05 AM.
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 02-23-08   #4 (permalink)
Miscelaneous
 
Licht's Avatar
 
amd ati

Join Date: Mar 2007
Location: Bel Air
Posts: 9,933
Blog Entries: 3

Rep: 289 Licht is a proven memberLicht is a proven memberLicht is a proven member
Unique Rep: 188
Folding Team Rank: 904
Trader Rating: 0
Default

Quote:
Originally Posted by rabidgnome229 View Post
I know that they are very different, but there's no reason for those functions to behave differently

**EDIT**
I forgot to include the errors . They're string function errors - nothing to do with the filesystem stuff

Code:
gcc test2.c 
test2.c: In function ‘main’:
test2.c:18: warning: incompatible implicit declaration of built-in function ‘strlen’
test2.c:19: warning: incompatible implicit declaration of built-in function ‘strncpy’
Ok i thought you were trying to compile it the same way you do for Linux execution and expected it to run on OSX.

System: Uzicht #4
CPU
Athlon X2 5200+ Windsor
Motherboard
Gigabyte 790X AM2+
Memory
6GB Kingston DDR2 667MHZ
Graphics Card
Saphire HD 3870
Hard Drive
4x WD1600AAJS RAID0
Sound Card
X-Fi Extreme Gamer Fatality Professional
Power Supply
OCZ Game-X-Stream 700w
Case
NZXT Black Steel
CPU cooling
Xigmatec Rifle
GPU cooling
Stock Saphire 3870 Cooling
OS
Vista Home Premium x64 SP1
Monitor
Samsung SyncMaster 19"Wide
Licht is online now I fold for Overclock.net Overclocked Account Licht's Gallery   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 03:19 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.23460 seconds with 8 queries