 
   # A string, list, tuple or callable that returns a string, list or tuple,
   # containing the command line (with arguments) used to lint.
-  cmd: 'clang++ -cc1 -fsyntax-only -fno-caret-diagnostics -fcxx-exceptions -Wall -I' + path.dirname()
+  cmd: 'clang++ -cc1 -fsyntax-only -fno-caret-diagnostics -fcxx-exceptions -Wall -I.'
 
   executablePath: null
 

linterPath = atom.packages.getLoadedPackage("linter").path
Linter = require "#{linterPath}/lib/linter"
path = require 'path'


  errorStream: 'stderr'

  fileName: ''

  # A regex pattern used to extract information from the executable's output.
  regex: '.+:(?<line>\\d+):.+: .*((?<error>error)|(?<warning>warning)): (?<message>.*)'

  lintFile: (filePath, callback) ->
    # build the command with arguments to lint the file
    {command, args} = @getCmdAndArgs(filePath)

    file = path.basename(args[args.length - 1])
    if file[file.length - 1] == @grammar
      file = file.replace(".", "\\.")
      file = file.replace("++", "\\+\\+")
      @regex = file + ':(?<line>\\d+):.+: .*((?<error>error)|(?<warning>warning)): (?<message>.*)'

    if atom.inDevMode()
      console.log 'is node executable: ' + @isNodeExecutable

    # use BufferedNodeProcess if the linter is node executable
    if @isNodeExecutable
      Process = BufferedNodeProcess
    else
      Process = BufferedProcess

    # options for BufferedProcess, same syntax with child_process.spawn
    options = {cwd: @cwd}

    stdout = (output) =>
      if atom.inDevMode()
        console.log 'stdout', output
      if @errorStream == 'stdout'
        @processMessage(output, callback)

    stderr = (output) =>
      if atom.inDevMode()
        console.warn 'stderr', output
      if @errorStream == 'stderr'
        @processMessage(output, callback)

    new Process({command, args, options, stdout, stderr})

  constructor: (editor) ->
    super(editor)
    if editor.getGrammar().name == 'C++'
      @cmd += ' -x c++';
      @grammar = '+'
    if editor.getGrammar().name == 'C'
      @grammar = 'c'

    atom.config.observe 'linter-clang.clangExecutablePath', =>
      @executablePath = atom.config.get 'linter-clang.clangExecutablePath'
