Loading macros in path from within a function

Hello, I have this function in my macro. The idea is that when I load the macro using

[quote] .x interana_plotter.C
[/quote]

it calls the below function, setting the style immediately for all the subsequent functions:

void interana_plotter(){
  gROOT->LoadMacro("AtlasStyle.C");
  SetAtlasStyle();
  gROOT->LoadMacro("AtlasLabels.C");
}

but I get the error:

/Users/Stuart/lab-book/code/interana/macros/interana_plotter.C:3:3: error: use of undeclared identifier 'SetAtlasStyle'
  SetAtlasStyle();

  ^
Error in <TInterpreter::AutoParse>: Error parsing payload code for class EColor with content:

#line 1 "libCore dictionary payload"

#ifndef G__VECTOR_HAS_CLASS_ITERATOR
  #define G__VECTOR_HAS_CLASS_ITERATOR 1
#endif
#ifndef SYSTEM_TYPE_macosx
  #define SYSTEM_TYPE_macosx 1
#endif
#ifndef SYSTEM_TYPE_unix
  #define SYSTEM_TYPE_unix 1
#endif

#define _BACKWARD_BACKWARD_WARNING_H
#include "TApplication.h"
#include "TApplicationImp.h"
#include "TAtt3D.h"
#include "TAttAxis.h"
#include "TAttBBox.h"
#include "TAttBBox2D.h"
#include "TAttFill.h"
#include "TAttLine.h"
#include "TAttMarker.h"
#include "TAttPad.h"
#include "TAttText.h"
#include "TBase64.h"
#include "TBenchmark.h"
#include "TBrowser.h"
#include "TBrowserImp.h"
#include "TBuffer.h"
#include "TBuffer3D.h"
#include "TBuffer3DTypes.h"
#include "TCanvasImp.h"
#include "TColor.h"
#include "TColorGradient.h"
#include "TContextMenu.h"
#include "TContextMenuImp.h"
#include "TControlBarImp.h"
#include "TDatime.h"
#include "TDirectory.h"
#include "TEnv.h"
#include "TError.h"
#include "TException.h"
#include "TExec.h"
#include "TFileCollection.h"
#include "TFileInfo.h"
#include "TFolder.h"
#include "TGuiFactory.h"
#include "TInetAddress.h"
#include "TInspectorImp.h"
#include "TMD5.h"
#include "TMacro.h"
#include "TMathBase.h"
#include "TMemberInspector.h"
#include "TMessageHandler.h"
#include "TNamed.h"
#include "TObjString.h"
#include "TObject.h"
#include "TObjectSpy.h"
#include "TPRegexp.h"
#include "TParameter.h"
#include "TPluginManager.h"
#include "TPoint.h"
#include "TProcessID.h"
#include "TProcessUUID.h"
#include "TQClass.h"
#include "TQCommand.h"
#include "TQConnection.h"
#include "TQObject.h"
#include "TQObjectEmitVA.h"
#include "TROOT.h"
#include "TRedirectOutputGuard.h"
#include "TRef.h"
#include "TRefCnt.h"
#include "TRegexp.h"
#include "TRemoteObject.h"
#include "TRootIOCtor.h"
#include "TStopwatch.h"
#include "TStorage.h"
#include "TString.h"
#include "TStringLong.h"
#include "TStyle.h"
#include "TSysEvtHandler.h"
#include "TSystem.h"
#include "TSystemDirectory.h"
#include "TSystemFile.h"
#include "TTask.h"
#include "TThreadSlots.h"
#include "TTime.h"
#include "TTimeStamp.h"
#include "TTimer.h"
#include "TUUID.h"
#include "TUri.h"
#include "TUrl.h"
#include "TVersionCheck.h"
#include "TVirtualAuth.h"
#include "TVirtualFFT.h"
#include "TVirtualGL.h"
#include "TVirtualMonitoring.h"
#include "TVirtualMutex.h"
#include "TVirtualPS.h"
#include "TVirtualPad.h"
#include "TVirtualPadEditor.h"
#include "TVirtualPadPainter.h"
#include "TVirtualPerfStats.h"
#include "TVirtualTableInterface.h"
#include "TVirtualViewer3D.h"
#include "TVirtualX.h"
#include "GuiTypes.h"
#include "KeySymbols.h"
#include "Buttons.h"
#include "strlcpy.h"
#include "snprintf.h"
#include "TArray.h"
#include "TArrayC.h"
#include "TArrayD.h"
#include "TArrayF.h"
#include "TArrayI.h"
#include "TArrayL.h"
#include "TArrayL64.h"
#include "TArrayS.h"
#include "TBits.h"
#include "TBtree.h"
#include "TClassTable.h"
#include "TClonesArray.h"
#include "TCollection.h"
#include "TCollectionProxyInfo.h"
#include "TExMap.h"
#include "THashList.h"
#include "THashTable.h"
#include "TIterator.h"
#include "TList.h"
#include "TMap.h"
#include "TObjArray.h"
#include "TObjectTable.h"
#include "TOrdCollection.h"
#include "TRefArray.h"
#include "TRefTable.h"
#include "TSeqCollection.h"
#include "TSortedList.h"
#include "TVirtualCollectionProxy.h"
#include "TMacOSXSystem.h"
#include "TUnixSystem.h"
#include "ESTLType.h"
#include "RConversionRuleParser.h"
#include "RStringView.h"
#include "TClassEdit.h"
#include "TClingRuntime.h"
#include "TSchemaRuleProcessor.h"
#include "TSchemaType.h"
#include "root_std_complex.h"
#include "TBaseClass.h"
#include "TClass.h"
#include "TClassGenerator.h"
#include "TClassMenuItem.h"
#include "TClassRef.h"
#include "TClassStreamer.h"
#include "TDataMember.h"
#include "TDataType.h"
#include "TDictAttributeMap.h"
#include "TDictionary.h"
#include "TEnum.h"
#include "TEnumConstant.h"
#include "TFileMergeInfo.h"
#include "TFunction.h"
#include "TFunctionTemplate.h"
#include "TGenericClassInfo.h"
#include "TGlobal.h"
#include "TInterpreter.h"
#include "TInterpreterValue.h"
#include "TIsAProxy.h"
#include "TListOfDataMembers.h"
#include "TListOfEnums.h"
#include "TListOfEnumsWithLock.h"
#include "TListOfFunctionTemplates.h"
#include "TListOfFunctions.h"
#include "TMemberStreamer.h"
#include "TMethod.h"
#include "TMethodArg.h"
#include "TMethodCall.h"
#include "TProtoClass.h"
#include "TRealData.h"
#include "TSchemaHelper.h"
#include "TSchemaRule.h"
#include "TSchemaRuleSet.h"
#include "TStreamer.h"
#include "TStreamerElement.h"
#include "TToggle.h"
#include "TToggleGroup.h"
#include "TVirtualIsAProxy.h"
#include "TVirtualRefProxy.h"
#include "TVirtualStreamerInfo.h"
#include "Getline.h"

#undef  _BACKWARD_BACKWARD_WARNING_H

If I type in the code manually it is fine, because the atlas style macros are in my path defined in my .rootrc.

What is going on here? It appears that when defined within a function, it needs to know all the symbols defined within, but I don’t know how to load the macros otherwise! Presumably there is an easy fix.

Try:
gROOT->ProcessLineSync(“SetAtlasStyle();”);