zoukankan      html  css  js  c++  java
  • c 宏 helloworld

    a.h

    #ifndef A_H_                                                                                                                                                                     
    #define A_H_
    typedef
    long int int4;
    #define MAX( x, y ) ( ((x) > (y)) ? (x) : (y) )
    #define g_new(structs) malloc(sizeof(structs))


    int
    add_count (
    int a, int b);



    #endif

      

    a.c

    #include     "a.h"                                                                                                                                                               

    int
    add_count (
    int a, int b)
    {
    return a + b;
    }
    /* ----- end of function add_count ----- */

      

    main.c

    #include        <errno.h>
    #include
    <math.h>
    #include
    <stdio.h>
    #include
    <stdlib.h>
    #include
    <string.h>
    #include
    "a.h"


    typedef
    struct PageStr PageStrCPN;


    struct PageStr
    {
    char* p_ch_data;
    int a;
    int b;
    };

    int
    main (
    int argc, char *argv[] )
    {
    int4 a
    = 10 , b = 100;
    char *c = g_new(PageStrCPN);
    ((PageStrCPN
    *)c)->a = 10;
    printf (
    "\nProgram %d\n\n", ((PageStrCPN*)c)->a );
    printf (
    "\nProgram %d\n\n",(int)MAX(a, b) );
    free(c);
    return EXIT_SUCCESS;
    }
    /* ---------- end of function main ---------- */

      

    编译:Makefile

    all:main                                                                                                                                                                         
    main:main.c a.c
    gcc
    -g -Wall -O0 main.c a.c -o main

      

    ******output*******

    Program
    10


    Program
    100

      

  • 相关阅读:
    Linux file命令详解
    Linux stat命令详解
    Linux cut命令详解
    Linux tr命令详解
    Linux grep/egrep命令详解
    Linux awk命令详解
    Linux xargs命令详解
    MVC设计模式
    qt博客
    android
  • 原文地址:https://www.cnblogs.com/wangkangluo1/p/2112524.html
Copyright © 2011-2022 走看看