# Can't compile the same C++ code on other computers including ROOT?

**URL:** <https://root-forum.cern.ch/t/cant-compile-the-same-c-code-on-other-computers-including-root/54751>\
**Category:** Newbie\
**Created:** [May 5, 2023, 10:20am UTC](https://root-forum.cern.ch/t/cant-compile-the-same-c-code-on-other-computers-including-root/54751 "2023-05-05T10:20:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![grattoni](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/8491ac/32.png) [@grattoni](https://root-forum.cern.ch/u/grattoni)\
**Post date:** [May 5, 2023, 10:20am UTC](https://root-forum.cern.ch/t/cant-compile-the-same-c-code-on-other-computers-including-root/54751/1 "2023-05-05T10:20:06Z")

</div>

* * *

\_ROOT Version:\_ROOT 6.26/06  
\_Platform:\_macOS Monterey  
_Compiler:_ clang

* * *

This is my makefile,  
`	$(CXX) $(FLAGS) $(LIBS) -arch $(ARCH) -o $@ $^`  
where

```auto
CXX = $(shell root-config --cxx)
FLAGS = $(shell root-config --cflags) -O2 -Wall -Wextra
LIBS = $(shell root-config --libs)
ARCH = x86_64

```

when I run this code on my macOS, it works completely fine. I tried it on other macs that are the same model as mine and had some errors. The program does not work correctly on them. I don’t understand what the problem is. These are the errors I get:

```auto
In file included from main/functions.cpp:1:
In file included from main/essential.h:47:
In file included from /opt/homebrew/Cellar/root/6.26.06_2/include/root/TTree.h:46:
In file included from /opt/homebrew/Cellar/root/6.26.06_2/include/root/TBranch.h:29:
In file included from /opt/homebrew/Cellar/root/6.26.06_2/include/root/TBranchCacheInfo.h:25:
/opt/homebrew/Cellar/root/6.26.06_2/include/root/TBits.h:150:11: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
   return (Bool_t)lhs & rhs;
          ^ ~~~~~~~~~~~~~~~~
                      &&
/opt/homebrew/Cellar/root/6.26.06_2/include/root/TBits.h:150:11: note: cast one or both operands to int to silence this warning
/opt/homebrew/Cellar/root/6.26.06_2/include/root/TBits.h:155:11: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical]
   return (Bool_t)lhs | rhs;
          ^ ~~~~~~~~~~~~~~~~
                      ||
/opt/homebrew/Cellar/root/6.26.06_2/include/root/TBits.h:155:11: note: cast one or both operands to int to silence this warning
In file included from main/functions.cpp:1:
In file included from main/essential.h:50:
In file included from /opt/homebrew/Cellar/root/6.26.06_2/include/root/TCanvas.h:15:
In file included from /opt/homebrew/Cellar/root/6.26.06_2/include/root/TPad.h:15:
In file included from /opt/homebrew/Cellar/root/6.26.06_2/include/root/TVirtualPad.h:30:
In file included from /opt/homebrew/Cellar/root/6.26.06_2/include/root/TQObject.h:42:
/opt/homebrew/Cellar/root/6.26.06_2/include/root/TVirtualQConnection.h:53:42: warning: 'sizeof (val)' will return the size of the pointer, not the array itself [-Wsizeof-pointer-div]
      constexpr size_t size = sizeof(val)/sizeof(val[0]);
                              ~~~~~~~~~~~ ^
/opt/homebrew/Cellar/root/6.26.06_2/include/root/TVirtualQConnection.h:51:25: note: pointer 'val' declared here
   void SetArg(const T* val)
                        ^

```

I also downloaded ROOT via brew on my computer. Also, I had the same type of warning on a computer where the ROOT was included in a Conda env. How should I compile my code so that it could work on both Mac and Linux?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [May 5, 2023, 11:24am UTC](https://root-forum.cern.ch/t/cant-compile-the-same-c-code-on-other-computers-including-root/54751/2 "2023-05-05T11:24:27Z")

</div>

The first two warnings (“bitwise-instead-of-logical”) are fixed in newer ROOT versions.

The last warning (“sizeof-pointer-div”) looks like a real bug and is [“removed” in the newest ROOT versions](https://github.com/root-project/root/commit/2e66a18ff1dbe2c994f657f97ce25530b2b56bf6):

```cpp
{
  double a[] = {1., 2., 3.};
  double *p = a;
  std::cout << "o.k. : " << sizeof(a) / sizeof(a[0]) << "\n";
  std::cout << "wrong: " << sizeof(p) / sizeof(p[0]) << "\n"; 
}

```
