Warning: attribute directive 'pred_aligned' is ignored

I just started with C ++, and I think the best way is to look at the source. I have code in the header file.

#ifdef _MSC_VER
#define MYAPP_CACHE_ALIGNED_RETURN /* not supported */
#else
#define MYAPP_CACHE_ALIGNED_RETURN __attribute__((assume_aligned(64)))
#endif

I use gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11)and its pretty old. I get this warning at compile time:

 warning: 'assume_aligned' attribute directiv e ignored [-Wattributes] –

How can I make the if statement more specific to fix a warning at compile time?

+4
source share
1 answer

It assume_aligneddoesn't seem to be supported on RHEL GCC (it was not passed to the upstream branch of gcc-4_8, nor is it available on Ubuntu 14.04 GCC 4.8.4, so this is not surprising).

, GCC :

#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 9)
#  warning "Your version of GCC does not support 'assume_aligned' attribute"
#endif

, back-ported assume_aligned ( RedHat Ubuntu, ). - configure script Makefile:

CFLAGS += $(shell echo 'void* my_alloc1() __attribute__((assume_aligned(16)));' | gcc -x c - -c -o /dev/null -Werror && echo -DHAS_ASSUME_ALIGNED)

HAS_ASSUME_ALIGNED , .

, __builtin_assume_aligned:

void foo() {
  double *p = func_that_misses_assume_align();
  p = __builtin_assume_aligned(p, 128);
  ...
}
+2

Source: https://habr.com/ru/post/1666998/


All Articles