blob: be435c3256ff5bcdaa87a34e13d6a74e04439834 [file] [log] [blame]
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +01001#include "examples/cpp/hello-lib.h"
2
Kristina Chodorowf01b2292015-03-02 16:08:28 +00003#include <string>
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +01004
Kristina Chodorowf01b2292015-03-02 16:08:28 +00005using hello::HelloLib;
6using std::string;
7
8/**
9 * This prints "Hello world". If it is run with arguments, it will use the first
10 * argument instead of "world". Build and run //examples/cpp:hello-world to see
11 * this program in action.
12 *
13 * This file does double-duty as a "test." It is a cc_binary, so it can also be
14 * compiled as a cc_test and Bazel will decide on whether it passed or failed
15 * based on exit code (which is always 0 here, so the test "passes"). See
16 * hello-fail.cc for an example of making a test fail.
17 */
18int main(int argc, char** argv) {
19 HelloLib lib("Hello");
20 string thing = "world";
21 if (argc > 1) {
22 thing = argv[1];
23 }
24 lib.greet(thing);
Han-Wen Nienhuysd08b27f2015-02-25 16:45:20 +010025 return 0;
26}