revision #1: 第 1 章增加了对 C++17 的支持

This commit is contained in:
Changkun Ou
2018-03-30 14:18:50 +02:00
parent 650ae66792
commit 51282838f8
9 changed files with 207 additions and 222 deletions

BIN
code/1/1.1 Executable file

Binary file not shown.

View File

@@ -1,13 +1,19 @@
//
// 1.1.cpp
//
// chapter 1 introduction
// c++1x tutorial
//
// created by changkun at changkun.de
//
#include "foo.h"
#include <iostream>
#include <functional>
int main() {
add(1, 2);
[out = std::ref(std::cout << "Result from C code: " << add(1, 2))](){
out.get() << ".\n";
}();
return 0;
}

View File

@@ -1,6 +1,25 @@
#
# 1.1.cpp
#
# chapter 1 introduction
# c++1x tutorial
#
# created by changkun at changkun.de
#
C = gcc
CXX = g++
SOURCE_C = foo.c
OBJECTS_C = foo.o
SOURCE_CXX = 1.1.cpp
TARGET = 1.1
LDFLAGS_COMMON = -std=c++1z
all:
gcc -c foo.c
g++ 1.1.cpp foo.o -o $(TARGET)
$(C) -c $(SOURCE_C)
$(CXX) $(SOURCE_CXX) $(OBJECTS_C) $(LDFLAGS_COMMON) -o $(TARGET)
clean:
rm -rf *.o $(TARGET)

View File

@@ -1,11 +1,12 @@
//
// foo.c
//
// chapter 1 introduction
// c++1x tutorial
//
// created by changkun at changkun.de
//
#include "foo.h"
int add(int x, int y) {

View File

@@ -1,11 +1,12 @@
//
// foo.h
//
// chapter 1 introduction
// c++1x tutorial
//
// created by changkun at changkun.de
//
#ifdef __cplusplus
extern "C" {
#endif