⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stddef.h

📁 PIC18F452 PWM程序,CCP1 CCP2模拟程序
💻 H
字号:
/* $Id: stddef.h,v 1.1 2003/12/09 22:54:19 GrosbaJ Exp $ */
#ifndef __STDDEF_H
#define __STDDEF_H

#if __18CXX

typedef unsigned char wchar_t;
typedef unsigned char size_t;   /* result type of sizeof operator */

/* ptrdiff_t is a bit tricky for a PIC because of the Harvard architecture.
 * We'll use the data memory size for the generic and define additional types
 * for specifics.
 */
typedef signed short int ptrdiff_t;
typedef signed short int ptrdiffram_t;
typedef signed short long int ptrdiffrom_t;

/* size_t is tricky as well, for the same reason. 16 bits is sufficient
 * for data objects, but 24-bits are necessary for program memory objects.
 * This is true even for the 17Cxx architecture, as size_t is in bytes, and
 * the 17Cxx has an address range of 128Kbytes. We'll do the same thing
 * as we did for ptrdiff_t.
 */
typedef unsigned short int size_t;
typedef unsigned short int sizeram_t;
typedef unsigned short long int sizerom_t;

/* NULL is a simple one. Many compilers define NULL as ((void*)0), which
 * is not best. A pointer to void is a pointer to data and a comparison
 * to a function pointer is a type mismatch and should result in an
 * error. The ANSI/ISO standard makes no guarantees about pointers to
 * data and pointers to code being at all related to one another.
 *
 * Since the standard requires that a pointer comparison to an integral
 * constant value of zero be allowed and is equivalent to a comparison
 * to the NULL pointer constant, we define NULL very simply, as '0'.
 */
#define NULL 0

/* offsetof() is a bit trickier. We define it in the standard way. The
 * compiler should be smart enough to evaluate the expression at compile
 * time and not run-time. It has to be as offsetof() is required by
 * 4.1.5 to evaluate to an integer constant expression.
 */
#define offsetof(type, member_designator) (size_t)(&(((type *)0)->member_designator))

#else
/* The MPLAB-C17 version. */
#define NULL    0

typedef unsigned char wchar_t;
typedef unsigned char size_t;   /* result type of sizeof operator */

typedef union tag_bits
{
  struct
  {
    unsigned   b0:1;
    unsigned   b1:1;
    unsigned   b2:1;
    unsigned   b3:1;
    unsigned   b4:1;
    unsigned   b5:1;
    unsigned   b6:1;
    unsigned   b7:1;
  };
  unsigned char byte;
} bits;

#endif  /* __18CXX */

#endif  /* __STDDEF_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -