]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/gcc/extensions-to-the-c-language-family/pragmas-accepted-by-gcc.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / gcc / extensions-to-the-c-language-family / pragmas-accepted-by-gcc.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. index:: pragmas, #pragma
7
8 .. _pragmas:
9
10 Pragmas Accepted by GCC
11 ***********************
12
13 GCC supports several types of pragmas, primarily in order to compile
14 code originally written for other compilers. Note that in general
15 we do not recommend the use of pragmas; See :ref:`function-attributes`,
16 for further explanation.
17
18 The GNU C preprocessor recognizes several pragmas in addition to the
19 compiler pragmas documented here. Refer to the CPP manual for more
20 information.
21
22 .. toctree::
23 :maxdepth: 2
24
25
26 .. _aarch64-pragmas:
27
28 AArch64 Pragmas
29 ^^^^^^^^^^^^^^^
30
31 The pragmas defined by the AArch64 target correspond to the AArch64
32 target function attributes. They can be specified as below:
33
34 .. code-block:: c++
35
36 #pragma GCC target("string")
37
38 where ``string`` can be any string accepted as an AArch64 target
39 attribute. See :ref:`aarch64-function-attributes`, for more details
40 on the permissible values of ``string``.
41
42 .. _arm-pragmas:
43
44 ARM Pragmas
45 ^^^^^^^^^^^
46
47 The ARM target defines pragmas for controlling the default addition of
48 :arm-fn-attr:`long_call` and ``short_call`` attributes to functions.
49 See :ref:`function-attributes`, for information about the effects of these
50 attributes.
51
52 ``long_calls``
53
54 .. index:: pragma, long_calls
55
56 Set all subsequent functions to have the :arm-fn-attr:`long_call` attribute.
57
58 ``no_long_calls``
59
60 .. index:: pragma, no_long_calls
61
62 Set all subsequent functions to have the ``short_call`` attribute.
63
64 ``long_calls_off``
65
66 .. index:: pragma, long_calls_off
67
68 Do not affect the :arm-fn-attr:`long_call` or ``short_call`` attributes of
69 subsequent functions.
70
71 .. _m32c-pragmas:
72
73 M32C Pragmas
74 ^^^^^^^^^^^^
75
76 :samp:`GCC memregs {number}`
77
78 .. index:: pragma, memregs
79
80 Overrides the command-line option ``-memregs=`` for the current
81 file. Use with care! This pragma must be before any function in the
82 file, and mixing different memregs values in different objects may
83 make them incompatible. This pragma is useful when a
84 performance-critical function uses a memreg for temporary values,
85 as it may allow you to reduce the number of memregs used.
86
87 :samp:`ADDRESS {name}{address}`
88
89 .. index:: pragma, address
90
91 For any declared symbols matching :samp:`{name}`, this does three things
92 to that symbol: it forces the symbol to be located at the given
93 address (a number), it forces the symbol to be volatile, and it
94 changes the symbol's scope to be static. This pragma exists for
95 compatibility with other compilers, but note that the common
96 ``1234H`` numeric syntax is not supported (use ``0x1234``
97 instead). Example:
98
99 .. code-block:: c++
100
101 #pragma ADDRESS port3 0x103
102 char port3;
103
104 .. _mep-pragmas:
105
106 MeP Pragmas
107 ^^^^^^^^^^^
108
109 ``custom io_volatile (on|off)``
110
111 .. index:: pragma, custom io_volatile
112
113 Overrides the command-line option ``-mio-volatile`` for the current
114 file. Note that for compatibility with future GCC releases, this
115 option should only be used once before any :mep-var-attr:`io` variables in each
116 file.
117
118 :samp:`GCC coprocessor available {registers}`
119
120 .. index:: pragma, coprocessor available
121
122 Specifies which coprocessor registers are available to the register
123 allocator. :samp:`{registers}` may be a single register, register range
124 separated by ellipses, or comma-separated list of those. Example:
125
126 .. code-block:: c++
127
128 #pragma GCC coprocessor available $c0...$c10, $c28
129
130 :samp:`GCC coprocessor call_saved {registers}`
131
132 .. index:: pragma, coprocessor call_saved
133
134 Specifies which coprocessor registers are to be saved and restored by
135 any function using them. :samp:`{registers}` may be a single register,
136 register range separated by ellipses, or comma-separated list of
137 those. Example:
138
139 .. code-block:: c++
140
141 #pragma GCC coprocessor call_saved $c4...$c6, $c31
142
143 :samp:`GCC coprocessor subclass '(A|B|C|D)' = {registers}`
144
145 .. index:: pragma, coprocessor subclass
146
147 Creates and defines a register class. These register classes can be
148 used by inline ``asm`` constructs. :samp:`{registers}` may be a single
149 register, register range separated by ellipses, or comma-separated
150 list of those. Example:
151
152 .. code-block:: c++
153
154 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
155
156 asm ("cpfoo %0" : "=B" (x));
157
158 :samp:`GCC disinterrupt {name} , {name} ...`
159
160 .. index:: pragma, disinterrupt
161
162 For the named functions, the compiler adds code to disable interrupts
163 for the duration of those functions. If any functions so named
164 are not encountered in the source, a warning is emitted that the pragma is
165 not used. Examples:
166
167 .. code-block:: c++
168
169 #pragma disinterrupt foo
170 #pragma disinterrupt bar, grill
171 int foo () { ... }
172
173 :samp:`GCC call {name} , {name} ...`
174
175 .. index:: pragma, call
176
177 For the named functions, the compiler always uses a register-indirect
178 call model when calling the named functions. Examples:
179
180 .. code-block:: c++
181
182 extern int foo ();
183 #pragma call foo
184
185 .. _pru-pragmas:
186
187 PRU Pragmas
188 ^^^^^^^^^^^
189
190 :samp:`ctable_entry {index}{constant_address}`
191
192 .. index:: pragma, ctable_entry
193
194 Specifies that the PRU CTABLE entry given by :samp:`{index}` has the value
195 :samp:`{constant_address}`. This enables GCC to emit LBCO/SBCO instructions
196 when the load/store address is known and can be addressed with some CTABLE
197 entry. For example:
198
199 .. code-block:: c++
200
201 /* will compile to "sbco Rx, 2, 0x10, 4" */
202 #pragma ctable_entry 2 0x4802a000
203 *(unsigned int *)0x4802a010 = val;
204
205 .. _rs-6000-and-powerpc-pragmas:
206
207 RS/6000 and PowerPC Pragmas
208 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
209
210 The RS/6000 and PowerPC targets define one pragma for controlling
211 whether or not the :powerpc-fn-attr:`longcall` attribute is added to function
212 declarations by default. This pragma overrides the :option:`-mlongcall`
213 option, but not the :powerpc-fn-attr:`longcall` and ``shortcall`` attributes.
214 See :ref:`rs-6000-and-powerpc-options`, for more information about when long
215 calls are and are not necessary.
216
217 ``longcall (1)``
218
219 .. index:: pragma, longcall
220
221 Apply the :powerpc-fn-attr:`longcall` attribute to all subsequent function
222 declarations.
223
224 ``longcall (0)``
225 Do not apply the :powerpc-fn-attr:`longcall` attribute to subsequent function
226 declarations.
227
228 .. Describe h8300 pragmas here.
229 Describe sh pragmas here.
230 Describe v850 pragmas here.
231
232 .. _s-390-pragmas:
233
234 S/390 Pragmas
235 ^^^^^^^^^^^^^
236
237 The pragmas defined by the S/390 target correspond to the S/390
238 target function attributes and some the additional options:
239
240 :samp:`zvector`
241 :samp:`no-zvector`
242
243 Note that options of the pragma, unlike options of the target
244 attribute, do change the value of preprocessor macros like
245 ``__VEC__``. They can be specified as below:
246
247 .. code-block:: c++
248
249 #pragma GCC target("string[,string]...")
250 #pragma GCC target("string"[,"string"]...)
251
252 .. _darwin-pragmas:
253
254 Darwin Pragmas
255 ^^^^^^^^^^^^^^
256
257 The following pragmas are available for all architectures running the
258 Darwin operating system. These are useful for compatibility with other
259 Mac OS compilers.
260
261 :samp:`mark {tokens}...`
262
263 .. index:: pragma, mark
264
265 This pragma is accepted, but has no effect.
266
267 :samp:`options align={alignment}`
268
269 .. index:: pragma, options align
270
271 This pragma sets the alignment of fields in structures. The values of
272 :samp:`{alignment}` may be ``mac68k``, to emulate m68k alignment, or
273 ``power``, to emulate PowerPC alignment. Uses of this pragma nest
274 properly; to restore the previous setting, use ``reset`` for the
275 :samp:`{alignment}`.
276
277 :samp:`segment {tokens}...`
278
279 .. index:: pragma, segment
280
281 This pragma is accepted, but has no effect.
282
283 :samp:`unused ({var} [, {var}]...)`
284
285 .. index:: pragma, unused
286
287 This pragma declares variables to be possibly unused. GCC does not
288 produce warnings for the listed variables. The effect is similar to
289 that of the :var-attr:`unused` attribute, except that this pragma may appear
290 anywhere within the variables' scopes.
291
292 .. _solaris-pragmas:
293
294 Solaris Pragmas
295 ^^^^^^^^^^^^^^^
296
297 The Solaris target supports ``#pragma redefine_extname``
298 (see :ref:`symbol-renaming-pragmas`). It also supports additional
299 ``#pragma`` directives for compatibility with the system compiler.
300
301 :samp:`align {alignment} ({variable} [, {variable}]...)`
302
303 .. index:: pragma, align
304
305 Increase the minimum alignment of each :samp:`{variable}` to :samp:`{alignment}`.
306 This is the same as GCC's :var-attr:`aligned` attribute see :ref:`variable-attributes`). Macro expansion occurs on the arguments to this pragma
307 when compiling C and Objective-C. It does not currently occur when
308 compiling C++, but this is a bug which may be fixed in a future
309 release.
310
311 :samp:`fini ({function} [, {function}]...)`
312
313 .. index:: pragma, fini
314
315 This pragma causes each listed :samp:`{function}` to be called after
316 main, or during shared module unloading, by adding a call to the
317 ``.fini`` section.
318
319 :samp:`init ({function} [, {function}]...)`
320
321 .. index:: pragma, init
322
323 This pragma causes each listed :samp:`{function}` to be called during
324 initialization (before ``main``) or during shared module loading, by
325 adding a call to the ``.init`` section.
326
327 .. _symbol-renaming-pragmas:
328
329 Symbol-Renaming Pragmas
330 ^^^^^^^^^^^^^^^^^^^^^^^
331
332 GCC supports a ``#pragma`` directive that changes the name used in
333 assembly for a given declaration. While this pragma is supported on all
334 platforms, it is intended primarily to provide compatibility with the
335 Solaris system headers. This effect can also be achieved using the asm
336 labels extension (see :ref:`asm-labels`).
337
338 :samp:`redefine_extname {oldname}{newname}`
339
340 .. index:: pragma, redefine_extname
341
342 This pragma gives the C function :samp:`{oldname}` the assembly symbol
343 :samp:`{newname}`. The preprocessor macro ``__PRAGMA_REDEFINE_EXTNAME``
344 is defined if this pragma is available (currently on all platforms).
345
346 This pragma and the ``asm`` labels extension interact in a complicated
347 manner. Here are some corner cases you may want to be aware of:
348
349 * This pragma silently applies only to declarations with external
350 linkage. The ``asm`` label feature does not have this restriction.
351
352 * In C++, this pragma silently applies only to declarations with
353 'C' linkage. Again, ``asm`` labels do not have this restriction.
354
355 * If either of the ways of changing the assembly name of a
356 declaration are applied to a declaration whose assembly name has
357 already been determined (either by a previous use of one of these
358 features, or because the compiler needed the assembly name in order to
359 generate code), and the new name is different, a warning issues and
360 the name does not change.
361
362 * The :samp:`{oldname}` used by ``#pragma redefine_extname`` is
363 always the C-language name.
364
365 .. _structure-layout-pragmas:
366
367 Structure-Layout Pragmas
368 ^^^^^^^^^^^^^^^^^^^^^^^^
369
370 For compatibility with Microsoft Windows compilers, GCC supports a
371 set of ``#pragma`` directives that change the maximum alignment of
372 members of structures (other than zero-width bit-fields), unions, and
373 classes subsequently defined. The :samp:`{n}` value below always is required
374 to be a small power of two and specifies the new alignment in bytes.
375
376 * ``#pragma pack(n)`` simply sets the new alignment.
377
378 * ``#pragma pack()`` sets the alignment to the one that was in
379 effect when compilation started (see also command-line option
380 :option:`-fpack-struct[=n]` see :ref:`code-gen-options`).
381
382 * ``#pragma pack(push[,n])`` pushes the current alignment
383 setting on an internal stack and then optionally sets the new alignment.
384
385 * ``#pragma pack(pop)`` restores the alignment setting to the one
386 saved at the top of the internal stack (and removes that stack entry).
387 Note that ``#pragma pack([n])`` does not influence this internal
388 stack; thus it is possible to have ``#pragma pack(push)`` followed by
389 multiple ``#pragma pack(n)`` instances and finalized by a single
390 ``#pragma pack(pop)``.
391
392 Some targets, e.g. x86 and PowerPC, support the ``#pragma ms_struct``
393 directive which lays out structures and unions subsequently defined as the
394 documented ``__attribute__ ((ms_struct))``.
395
396 * ``#pragma ms_struct on`` turns on the Microsoft layout.
397
398 * ``#pragma ms_struct off`` turns off the Microsoft layout.
399
400 * ``#pragma ms_struct reset`` goes back to the default layout.
401
402 Most targets also support the ``#pragma scalar_storage_order`` directive
403 which lays out structures and unions subsequently defined as the documented
404 ``__attribute__ ((scalar_storage_order))``.
405
406 * ``#pragma scalar_storage_order big-endian`` sets the storage order
407 of the scalar fields to big-endian.
408
409 * ``#pragma scalar_storage_order little-endian`` sets the storage order
410 of the scalar fields to little-endian.
411
412 * ``#pragma scalar_storage_order default`` goes back to the endianness
413 that was in effect when compilation started (see also command-line option
414 :option:`-fsso-struct=endianness` see :ref:`c-dialect-options`).
415
416 .. _weak-pragmas:
417
418 Weak Pragmas
419 ^^^^^^^^^^^^
420
421 For compatibility with SVR4, GCC supports a set of ``#pragma``
422 directives for declaring symbols to be weak, and defining weak
423 aliases.
424
425 :samp:`#pragma weak {symbol}`
426 This pragma declares :samp:`{symbol}` to be weak, as if the declaration
427 had the attribute of the same name. The pragma may appear before
428 or after the declaration of :samp:`{symbol}`. It is not an error for
429 :samp:`{symbol}` to never be defined at all.
430
431 :samp:`#pragma weak {symbol1} = {symbol2}`
432 This pragma declares :samp:`{symbol1}` to be a weak alias of :samp:`{symbol2}`.
433 It is an error if :samp:`{symbol2}` is not defined in the current
434 translation unit.
435
436 .. _diagnostic-pragmas:
437
438 Diagnostic Pragmas
439 ^^^^^^^^^^^^^^^^^^
440
441 GCC allows the user to selectively enable or disable certain types of
442 diagnostics, and change the kind of the diagnostic. For example, a
443 project's policy might require that all sources compile with
444 :option:`-Werror` but certain files might have exceptions allowing
445 specific types of warnings. Or, a project might selectively enable
446 diagnostics and treat them as errors depending on which preprocessor
447 macros are defined.
448
449 :samp:`#pragma GCC diagnostic {kind}{option}`
450 Modifies the disposition of a diagnostic. Note that not all
451 diagnostics are modifiable; at the moment only warnings (normally
452 controlled by :samp:`-W...`) can be controlled, and not all of them.
453 Use :option:`-fdiagnostics-show-option` to determine which diagnostics
454 are controllable and which option controls them.
455
456 :samp:`{kind}` is :samp:`error` to treat this diagnostic as an error,
457 :samp:`warning` to treat it like a warning (even if :option:`-Werror` is
458 in effect), or :samp:`ignored` if the diagnostic is to be ignored.
459 :samp:`{option}` is a double quoted string that matches the command-line
460 option.
461
462 .. code-block:: c++
463
464 #pragma GCC diagnostic warning "-Wformat"
465 #pragma GCC diagnostic error "-Wformat"
466 #pragma GCC diagnostic ignored "-Wformat"
467
468 Note that these pragmas override any command-line options. GCC keeps
469 track of the location of each pragma, and issues diagnostics according
470 to the state as of that point in the source file. Thus, pragmas occurring
471 after a line do not affect diagnostics caused by that line.
472
473 ``#pragma GCC diagnostic push``, ``#pragma GCC diagnostic pop``
474 Causes GCC to remember the state of the diagnostics as of each
475 ``push``, and restore to that point at each ``pop``. If a
476 ``pop`` has no matching ``push``, the command-line options are
477 restored.
478
479 .. code-block:: c++
480
481 #pragma GCC diagnostic error "-Wuninitialized"
482 foo(a); /* error is given for this one */
483 #pragma GCC diagnostic push
484 #pragma GCC diagnostic ignored "-Wuninitialized"
485 foo(b); /* no diagnostic for this one */
486 #pragma GCC diagnostic pop
487 foo(c); /* error is given for this one */
488 #pragma GCC diagnostic pop
489 foo(d); /* depends on command-line options */
490
491 ``#pragma GCC diagnostic ignored_attributes``
492 Similarly to :option:`-Wno-attributes=`, this pragma allows users to suppress
493 warnings about unknown scoped attributes (in C++11 and C2X). For example,
494 ``#pragma GCC diagnostic ignored_attributes "vendor::attr"`` disables
495 warning about the following declaration:
496
497 .. code-block:: c++
498
499 [[vendor::attr]] void f();
500
501 whereas ``#pragma GCC diagnostic ignored_attributes "vendor::"`` prevents
502 warning about both of these declarations:
503
504 .. code-block:: c++
505
506 [[vendor::safe]] void f();
507 [[vendor::unsafe]] void f2();
508
509 GCC also offers a simple mechanism for printing messages during compilation.
510
511 :samp:`#pragma message {string}`
512
513 .. index:: pragma, diagnostic
514
515 Prints :samp:`{string}` as a compiler message on compilation. The message
516 is informational only, and is neither a compilation warning nor an
517 error. Newlines can be included in the string by using the :samp:`\\n`
518 escape sequence.
519
520 .. code-block:: c++
521
522 #pragma message "Compiling " __FILE__ "..."
523
524 :samp:`{string}` may be parenthesized, and is printed with location
525 information. For example,
526
527 .. code-block:: fortran
528
529 #define DO_PRAGMA(x) _Pragma (#x)
530 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
531
532 TODO(Remember to fix this)
533
534 prints :samp:`/tmp/file.c:4: note: #pragma message:
535 TODO - Remember to fix this`.
536
537 :samp:`#pragma GCC error {message}`
538
539 .. index:: pragma, diagnostic
540
541 Generates an error message. This pragma *is* considered to
542 indicate an error in the compilation, and it will be treated as such.
543
544 Newlines can be included in the string by using the :samp:`\\n`
545 escape sequence. They will be displayed as newlines even if the
546 :option:`-fmessage-length` option is set to zero.
547
548 The error is only generated if the pragma is present in the code after
549 pre-processing has been completed. It does not matter however if the
550 code containing the pragma is unreachable:
551
552 .. code-block:: c++
553
554 #if 0
555 #pragma GCC error "this error is not seen"
556 #endif
557 void foo (void)
558 {
559 return;
560 #pragma GCC error "this error is seen"
561 }
562
563 :samp:`#pragma GCC warning {message}`
564
565 .. index:: pragma, diagnostic
566
567 This is just like :samp:`pragma GCC error` except that a warning
568 message is issued instead of an error message. Unless
569 :option:`-Werror` is in effect, in which case this pragma will generate
570 an error as well.
571
572 .. _visibility-pragmas:
573
574 Visibility Pragmas
575 ^^^^^^^^^^^^^^^^^^
576
577 :samp:`#pragma GCC visibility push({visibility})`, ``#pragma GCC visibility pop``
578
579 .. index:: pragma, visibility
580
581 This pragma allows the user to set the visibility for multiple
582 declarations without having to give each a visibility attribute
583 (see :ref:`function-attributes`).
584
585 In C++, :samp:`#pragma GCC visibility` affects only namespace-scope
586 declarations. Class members and template specializations are not
587 affected; if you want to override the visibility for a particular
588 member or instantiation, you must use an attribute.
589
590 .. _push-pop-macro-pragmas:
591
592 Push/Pop Macro Pragmas
593 ^^^^^^^^^^^^^^^^^^^^^^
594
595 For compatibility with Microsoft Windows compilers, GCC supports
596 :samp:`#pragma push_macro({"macro_name"})`
597 and :samp:`#pragma pop_macro({"macro_name"})`.
598
599 :samp:`#pragma push_macro({"macro_name"})`
600
601 .. index:: pragma, push_macro
602
603 This pragma saves the value of the macro named as :samp:`{macro_name}` to
604 the top of the stack for this macro.
605
606 :samp:`#pragma pop_macro({"macro_name"})`
607
608 .. index:: pragma, pop_macro
609
610 This pragma sets the value of the macro named as :samp:`{macro_name}` to
611 the value on top of the stack for this macro. If the stack for
612 :samp:`{macro_name}` is empty, the value of the macro remains unchanged.
613
614 For example:
615
616 .. code-block:: c++
617
618 #define X 1
619 #pragma push_macro("X")
620 #undef X
621 #define X -1
622 #pragma pop_macro("X")
623 int x [X];
624
625 In this example, the definition of X as 1 is saved by ``#pragma
626 push_macro`` and restored by ``#pragma pop_macro``.
627
628 .. _function-specific-option-pragmas:
629
630 Function Specific Option Pragmas
631 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
632
633 :samp:`#pragma GCC target ({string}, ...)`
634
635 .. index:: pragma GCC target
636
637 This pragma allows you to set target-specific options for functions
638 defined later in the source file. One or more strings can be
639 specified. Each function that is defined after this point is treated
640 as if it had been declared with one ``target(``:samp:`{string}` ``)``
641 attribute for each :samp:`{string}` argument. The parentheses around
642 the strings in the pragma are optional. See :ref:`function-attributes`,
643 for more information about the ``target`` attribute and the attribute
644 syntax.
645
646 The ``#pragma GCC target`` pragma is presently implemented for
647 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
648
649 :samp:`#pragma GCC optimize ({string}, ...)`
650
651 .. index:: pragma GCC optimize
652
653 This pragma allows you to set global optimization options for functions
654 defined later in the source file. One or more strings can be
655 specified. Each function that is defined after this point is treated
656 as if it had been declared with one ``optimize(``:samp:`{string}` ``)``
657 attribute for each :samp:`{string}` argument. The parentheses around
658 the strings in the pragma are optional. See :ref:`function-attributes`,
659 for more information about the ``optimize`` attribute and the attribute
660 syntax.
661
662 ``#pragma GCC push_options`` ``#pragma GCC pop_options``
663
664 .. index:: pragma GCC push_options, pragma GCC pop_options
665
666 These pragmas maintain a stack of the current target and optimization
667 options. It is intended for include files where you temporarily want
668 to switch to using a different :samp:`#pragma GCC target` or
669 :samp:`#pragma GCC optimize` and then to pop back to the previous
670 options.
671
672 ``#pragma GCC reset_options``
673
674 .. index:: pragma GCC reset_options
675
676 This pragma clears the current ``#pragma GCC target`` and
677 ``#pragma GCC optimize`` to use the default switches as specified
678 on the command line.
679
680 .. _loop-specific-pragmas:
681
682 Loop-Specific Pragmas
683 ^^^^^^^^^^^^^^^^^^^^^
684
685 ``#pragma GCC ivdep``
686
687 .. index:: pragma GCC ivdep
688
689 With this pragma, the programmer asserts that there are no loop-carried
690 dependencies which would prevent consecutive iterations of
691 the following loop from executing concurrently with SIMD
692 (single instruction multiple data) instructions.
693
694 For example, the compiler can only unconditionally vectorize the following
695 loop with the pragma:
696
697 .. code-block:: c++
698
699 void foo (int n, int *a, int *b, int *c)
700 {
701 int i, j;
702 #pragma GCC ivdep
703 for (i = 0; i < n; ++i)
704 a[i] = b[i] + c[i];
705 }
706
707 In this example, using the ``restrict`` qualifier had the same
708 effect. In the following example, that would not be possible. Assume
709 k < -m or k >= m. Only with the pragma, the compiler knows
710 that it can unconditionally vectorize the following loop:
711
712 .. code-block:: c++
713
714 void ignore_vec_dep (int *a, int k, int c, int m)
715 {
716 #pragma GCC ivdep
717 for (int i = 0; i < m; i++)
718 a[i] = a[i + k] * c;
719 }
720
721 :samp:`#pragma GCC unroll {n}`
722
723 .. index:: pragma GCC unroll n
724
725 You can use this pragma to control how many times a loop should be unrolled.
726 It must be placed immediately before a ``for``, ``while`` or ``do``
727 loop or a ``#pragma GCC ivdep``, and applies only to the loop that follows.
728 :samp:`{n}` is an integer constant expression specifying the unrolling factor.
729 The values of 0 and 1 block any unrolling of the loop.