07-16-2012
You are mistaken. This use of a fixed-width type makes your code less portable. However, this mistake is unlikely to cause a problem so long as you work with the widely-available 32 and 64 bit platforms.
As I recall, C requires main() to return int or void. If main() takes any arguments, argc must be an int.
On UNIX and Windows NT, on both 32-bit and 64-bit platforms, the data models specify a 32 bit int. On such platforms, int32_t is implemented using a typedef (or two) which essentially aliases int32_t to int, which is what the standard requires. So long as this is the case, the compiler is happy.
But, what would happen if you tried to compile that on a 16 bit machine? On a 16 bit machine, int32_t may be implemented with long. If that's the case, your code won't compile (if it does, there will likely be serious problems). A similar problem could arise if this code were compiled on a 64 bit architecture with 64 bit ints.
Regards,
Alister
This User Gave Thanks to alister For This Post:
10 More Discussions You Might Find Interesting
1. Programming
sometimes for this code i get a segmentation fault for codes llike this
:
int main{
int * a= 0;
int b;
a = (int*)malloc(sizeof(int));
///some code using these variable but no freeing of a
if(a){
free(a);
a = 0;
}
return... (3 Replies)
Discussion started by: wojtyla
3 Replies
2. Programming
I have written a program which takes a directory as command line arguments and displays all the dir and files in it.
I don't know why I have a problem with the /etc directory.It displays all the directories and files untill it reaches a sub directory called peers which is in /etc/ppp/peers.the... (4 Replies)
Discussion started by: vijlak
4 Replies
3. AIX
Hi ,
During execution a backup binary i get following error
"Program error 11 (Segmentation fault), saving core file in '/usr/datatools"
Riyaz (2 Replies)
Discussion started by: rshaikh
2 Replies
4. Programming
Hi,
I am having this segmentation fault not in the following program, bt. in my lab program . My lab program is horrible long so cannot post it here bt. I am using the following logic in my program which is giving the segmentation fault. Bt. if I run this sample program as it is it dosen't give... (3 Replies)
Discussion started by: mind@work
3 Replies
5. Programming
I'm getting a segmentation fault. I'm new to Linux programming. Thanks so much for all of your input.:eek:
#include </usr/include/mysql++/mysql++.h>
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <string.h>
using namespace std;
int outputToImport(const char*... (1 Reply)
Discussion started by: sepoto
1 Replies
6. UNIX for Dummies Questions & Answers
#include<stdio.h>
#include<malloc.h>
#include<unistd.h>
#include<stdlib.h>
void *start_1(void *argv)
{
printf("thread 0x%x\n",(unsigned int)pthread_self());
pthread_exit((void*)1);
}
void *start_2(void *argv)
{
printf("thread 0x%x\n",(unsigned int)pthread_self());
return (void*)2;
}... (2 Replies)
Discussion started by: vincent__tse
2 Replies
7. Programming
I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this :
i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies
8. Solaris
Hi Guys,
I just installed and booted a zone called testzone. When I logged in remotely and tried changing to root user I get this error:
"Segmentation fault"
Can someone please help me resolve this?
Thanks alot (2 Replies)
Discussion started by: cjashu
2 Replies
9. Shell Programming and Scripting
Hi everyone
Need to get version of npm application that have several output like this:
root: nmp -version
10
root: nmp -version
10
root: nmp-new -version
3.1
root: nmp-old -version
Segmentation fault
count them , after that write to the file like this:
10 2
3.1 1 (1 Reply)
Discussion started by: indeed_1
1 Replies
10. Programming
Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1...
I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one.
Below are two very condensed snippets of which I have added the results inside the each code section.
IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies
LEARN ABOUT REDHAT
types32.h
types32.h(3HEAD) Headers types32.h(3HEAD)
NAME
types32.h, types32 - fixed-width data types
SYNOPSIS
#include <sys/types32.h>
DESCRIPTION
The following fixed-width data types defined in <sys/types32.h> correspond to the sign and sizes of types in the 32-bit environment that
can be used for compatibility and interoperability purposes in either the 32-bit or 64-bit environment.
typedef int32_t blkcnt32_t
typedef uint32_t caddr32_t
typedef int32_t clock32_t
typedef int32_t daddr32_t
typedef uint32_t dev32_t
typedef uint32_t fsblkcnt32_t
typedef uint32_t fsfilcnt32_t
typedef int32_t gid32_t
typedef int32_t id32_t
typedef uint32_t ino32_t
typedef int32_t key32_t
typedef uint32_t major32_t
typedef uint32_t minor32_t
typedef uint32_t mode32_t
typedef uint32_t nlink32_t
typedef int32_t pid32_t
typedef uint32_t rlim32_t
typedef uint32_t size32_t
typedef int32_t ssize32_t
typedef time32_t int32_t
typedef uid32_t int32_t
SunOS 5.10 30 Oct 1997 types32.h(3HEAD)