compatibility.h 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. ==============================================================================*/
  12. #ifndef TENSORFLOW_LITE_MICRO_COMPATIBILITY_H_
  13. #define TENSORFLOW_LITE_MICRO_COMPATIBILITY_H_
  14. // C++ will automatically create class-specific delete operators for virtual
  15. // objects, which by default call the global delete function. For embedded
  16. // applications we want to avoid this, and won't be calling new/delete on these
  17. // objects, so we need to override the default implementation with one that does
  18. // nothing to avoid linking in ::delete().
  19. // This macro needs to be included in all subclasses of a virtual base class in
  20. // the private section.
  21. #ifdef TF_LITE_STATIC_MEMORY
  22. #define TF_LITE_REMOVE_VIRTUAL_DELETE \
  23. void operator delete(void* p) {}
  24. #else
  25. #define TF_LITE_REMOVE_VIRTUAL_DELETE
  26. #endif
  27. #endif // TENSORFLOW_LITE_MICRO_COMPATIBILITY_H_