title: Error: conflicting types when trying to make a simple syscall
body: <p>I'm brand new to Linux programming and I'm trying to implement a simple system call loosely following this guide: <a href="https://medium.com/anubhav-shrimal/adding-a-hello-world-system-call-to-linux-kernel-dad32875872" rel="nofollow noreferrer">https://medium.com/anubhav-shrimal/adding-a-hello-world-system-call-to-linux-kernel-dad32875872</a>. In my linux kernel directory, I created a new directory called <code>my_syscall</code>. Within that directory, I created <code>my_syscall.c</code>. Here is <code>my_syscall.c</code></p>
  
  <pre><code>#include &lt;linux/syscalls.h&gt;
  #include &lt;linux/kernel.h&gt;
  
  asmlinkage long sys_my_syscall(int i) {
     prink(KERN_INFO "This is the system call.");
     return(0);
  }
  </code></pre>
  
  <p>I then created a <code>Makefile</code> in the <code>my_syscall</code> directory with a single line:</p>
  
  <pre><code>obj-y := my_syscall.o
  </code></pre>
  
  <p>I then edited this line in the <code>Makefile</code> in the kernel directory to be:</p>
  
  <pre><code>core-y         += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ my_syscall/
  </code></pre>
  
  <p>Then, in the directory <code>linux-5.4.15/arch/x86/entry/syscalls</code>, I edited the <code>syscall_64.tbl</code> to include the following line at the very end:</p>
  
  <pre><code>548     64         my_syscall          sys_my_syscall
  </code></pre>
  
  <p>Finally, in the directory <code>linux-5.4.15/include/linux</code>, I edited the <code>syscalls.h</code> file to include this line before the <code>#endif</code>:</p>
  
  <pre><code>asmlinkage long sys_my_syscall(int i);
  </code></pre>
  
  <p>Now, when I run the command <code>sudo make</code>, I run into the following error soon after:</p>
  
  <pre><code>./arch/x86/include/generated/asm/syscalls_64.h:2664:19: error: conflicting types for 'sys_my_syscall'
  __SYSCALL_64(548, sys_my_syscall, )
  
  arch/x86/entry/syscall_64.c:18:60: note: in definition of macro '__SYSCALL-64'
    #define __SYSCALL_64(nr, sym, qual) extern asmlinkage long sym(const struct pt_regs *);
  
  In file included from arch/x86/entry/syscall_64.c:7:0:
  ./include/linux/syscalls.h:1423:17: note: previous declaration of 'sys_my_syscall' was here
   asmlinkage long sys_my_syscall(int i);
                   ^
  make[3]: *** [arch/x86/entry/syscall_64.o] Error 1
  make[2]: *** [arch/x86/entry] Error 2
  make[1]: *** [arch/x86] Error 2
  make: *** [sub-make] Error 2
  </code></pre>
  
  <p>I have no idea how to approach this error. With a conflicting types error, I would think I declared the syscall differently in someplace, but in both <code>my_syscall.c</code> and the <code>syscalls.h</code> files, the declaration is the same. These were the only two files where the syscall is declared, but it is also named within <code>syscall_64.tbl</code> and it seems like this is where linux is trying to point me towards. However, I don't see what's wrong with how I declared it in the table as I followed the guide directly. Any help with this would be greatly appreciated!</p>
  
  <p>Info:</p>
  
  <p>Kernel version: 5.4.15</p>
  
  <p>Linux Distribution: Ubuntu 14</p>