zoukankan      html  css  js  c++  java
  • C/C++之Exercise

    一.C/C++之初学Demo---C++调用C.h文件使用实例:

    工程结构:

    exercise.h code:

    1 #ifndef _EXERCISE_H_
    2 #define _EXERCISE_H_
    3 #include <externcpp.h>;
    4 extern "C"  
    5 {  
    6     #include <externc.h>;
    7 }
    8 #endif

    externc.h code:

    1 #ifndef _EXTERNC_H_
    2 #define _EXTERNC_H_
    3 #include <stdio.h>;
    4 
    5 void c_hello();
    6 
    7 #endif

    externcpp.h code:

    1 #ifndef _EXTERNCPP_H_
    2 #define _EXTERNCPP_H_
    3 #include <iostream>;
    4 using namespace std;
    5 
    6 void cpp_hello();
    7 
    8 #endif

    c_hello.c code:

    1 #include <externc.h>;
    2 
    3 void c_hello(){
    4     printf("C Hello World!");
    5     getchar();
    6 }

    cpp_hello.cpp code:

    1 #include <externcpp.h>;
    2 
    3 void cpp_hello(){
    4     cout<<"C++ Hello World!";
    5     getchar();
    6 }

    main.cpp code:

    1 #include <exercise.h>
    2 
    3 void main(){
    4     c_hello();
    5     cpp_hello();
    6 }

    二.VS2010及以上之错误C1083解决:

     "error C1083"这个错误是因为VS中C/C++常规配置中加载头文件的路径问题:

    解决方法:

    1)右键查看该项目的属性

    2)点击属性——〉配置属性  ——〉C/C++  ——〉  常规  ——〉附加包含目录 ——〉编辑

    3) 添加

    $(ProjectDir) // 工程目录

    $(ProjectDir)inc // 工程子目录

  • 相关阅读:
    springboot定时任务框架Quartz
    Linux中安装Erlang
    prometheus常用函数详解
    Prometheus+Grafana+SpringBoot业务埋点可视化监控
    Prometheus+Grafana可视化监控SpringBoot项目
    prometheus的数据类型介绍
    DS:顺序栈
    DS:顺序队列
    Linux:06进程
    primer5:chap09顺序容器
  • 原文地址:https://www.cnblogs.com/ysjshrine/p/4346688.html
Copyright © 2011-2022 走看看