mirror of
https://github.com/changkun/modern-cpp-tutorial.git
synced 2025-12-17 04:34:40 +03:00
revision #1: 第 1 章增加了对 C++17 的支持
This commit is contained in:
BIN
code/1/1.1
Executable file
BIN
code/1/1.1
Executable file
Binary file not shown.
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
//
|
||||
// foo.h
|
||||
//
|
||||
// chapter 1 introduction
|
||||
// c++1x tutorial
|
||||
//
|
||||
// created by changkun at changkun.de
|
||||
//
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user