diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b0e089..231fe6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ include_directories(.) add_executable( ${PROJECT_NAME} main.cpp + helloWorld.hpp + helloWorld.cpp beer.hpp beer.cpp ) diff --git a/bootstrap.sh b/bootstrap.sh index 0a9bea1..0db1feb 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -euo pipefail IFS=$'\n\t' @@ -16,11 +16,11 @@ if [[ Darwin = "$platform" ]]; then -fdiagnostics-fixit-info -fdiagnostics-parseable-fixits \ -fdiagnostics-print-source-range-info -fdiagnostics-show-option \ -fno-builtin -fshow-column -fshow-source-location -fstandalone-debug \ - -ftime-report main.cpp beer.cpp -o "HQ9+" + -ftime-report main.cpp helloWorld.cpp beer.cpp -o "HQ9+" elif [[ "Linux" = "$platform" ]]; then g++ --verbose -Wall -Wextra -pedantic -save-temps -v -fgnu-tm -lm -latomic \ - -lstdc++ -g -fgnat-encodings=all main.cpp beer.cpp -o "HQ9+" + -lstdc++ -g -fgnat-encodings=all main.cpp helloWorld.cpp beer.cpp -o "HQ9+" fi diff --git a/helloWorld.cpp b/helloWorld.cpp new file mode 100644 index 0000000..3832908 --- /dev/null +++ b/helloWorld.cpp @@ -0,0 +1,6 @@ +#include "helloWorld.hpp" +#include + +void helloWorld() { + std::cout << "Hello, world!" << std::endl; +} diff --git a/helloWorld.hpp b/helloWorld.hpp new file mode 100644 index 0000000..f9ced47 --- /dev/null +++ b/helloWorld.hpp @@ -0,0 +1,6 @@ +#ifndef HELLO_WORLD_HPP_ +#define HELLO_WORLD_HPP_ + +void helloWorld(); + +#endif // HELLO_WORLD_HPP_ diff --git a/main.cpp b/main.cpp index e146fa2..d26e0e0 100644 --- a/main.cpp +++ b/main.cpp @@ -3,6 +3,7 @@ #include #include +#include "helloWorld.hpp" #include "beer.hpp" #define BUFFER_SIZE INT_MAX / UCHAR_MAX - USHRT_MAX @@ -21,7 +22,7 @@ int main() { for (unsigned long long index = 0; index < strnlen(input, BUFFER_SIZE); index++) { if (input[index] == 'H') { - printf("Hello, world!\n"); + helloWorld(); } else if (input[index] == 'Q') { printf("%s\n", input); } else if (input[index] == '9') {