Note that there are some explanatory texts on larger screens.

plurals
  1. POclang Linker fails if at least -O2 wasn't used
    text
    copied!<p>I've an strage behaviour in a simple C code that I'm doing for educational purposes.</p> <p>If I compile it with something lower than -O2 it breaks during link-edition with this output.</p> <pre><code>$ make clang -Wall -march=native -pipe -c -g -D_DEBUG_ main.c clang -Wall -march=native -pipe -c -g -D_DEBUG_ functions.c clang -Wall -o main main.o functions.o Undefined symbols for architecture x86_64: "_getbit", referenced from: _getValueFromMatrix in functions.o "_setbit", referenced from: _populateMatrix in functions.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [main] Error 1 </code></pre> <p>I don't know if this helps but, here are the implementation of setbit(); and getbit();</p> <pre><code>inline void setbit(uint64_t *inteiro, unsigned char pos) { *(uint64_t*)inteiro |= (uint64_t)1 &lt;&lt; pos; } inline bool getbit(uint64_t inteiro, unsigned char pos) { return (inteiro &amp; ((uint64_t)1 &lt;&lt; pos)); } </code></pre> <p>EDIT:</p> <p>functions.h</p> <pre><code>#ifndef __FUNCTIONS_H__ #define __FUNCTIONS_H__ /* Funções para manipulação de bits */ inline void setbit(uint64_t *, unsigned char); inline void clearbit(uint64_t *, unsigned char); inline bool getbit(uint64_t, unsigned char); inline unsigned char getbitChar(uint64_t, unsigned char); char *uint64_t2bin(uint64_t, char *, int); #endif </code></pre> <p>Includes in main.c</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;stdint.h&gt; #include &lt;stdbool.h&gt; #include &lt;string.h&gt; #include "errors.h" #include "const.h" #include "types.h" #include "functions.h" </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload