Emacs Semantic will not handle files correctly on Windows

I recently switched my programming environment from CentOS to Windows. I'm an Emacs fan, so I want to use Emacs for Windows programming too. Everything goes smoothly, but when I use emacs semantics for parsing, this is where the problem arises.

It seems that emacs semantics will choose which file to parse and which not. I point out that MS Visual Studio includes directories for emacs for parsing, but it doesn't. I've also tried MinGW headers, but emacs only parses a few files. My init.el file is like this

(defun my-semantic-hook()
  (semantic-add-system-include "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\include")
  )

      

I don't know if I should use / or \ in emacs on windows, but both seem to work. And if I use semantic-c-describe-environment

, the output is

This file’s project include is handled by:
    EDE : #<ede-cpp-root-target ede-cpp-root-target>
     with the system path:
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include
    D:/WorkSpace/

  This file’s system include path is:
    /usr/include
    c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/include/

      

You can see that I also tried EDE to give the system path, but it doesn't work either. However, other features of the semantic works very well. If I write #include "lib1.h"

or #include "headers/lib1.h"

or using EDE #include <myproj/headers/lib1.h>

they all work well. However, when it comes to VS include files or MinGW include files, things go wrong. My guess is that if semantic checking the file first, and it found something wrong, then just skipped the file? Then how can I fix the problem?

Now the problem has new progress. I tried to use semantics in my old project using SDL2 library. After I wrote the project configuration for EDE and opened one of the source files, something happened. Semantic analysis of some systems includes files such as stdio.h. Then I can navigate to it via semantics.

Then I tried another file using iostream. However, the semantic still does not parse it. But I can use the command C-c , u

to navigate to the file and I manually call the semantics to parse it. Then I went back to the original file using iostream, the company's backend using semantics might work pretty well.

So now I can verify that the problem is that the semantics does not parse the file itself. Maybe because it only parses files with .h or .c at the end of the filename? But on linux it works well with files like iostream, why won't it be on windows? How to fix it?

+3


source to share


1 answer


  • add system includes example:

        (semantic-reset-system-include 'c-mode)
        (dolist (x 'your-system-includes)
          (semantic-add-system-include x 'c-mode))
    
          

  • add project roots:

    (setq semanticdb-project-roots 'your-project-roots)
    
          

There is an implementation of how to find the correct system on Windows, Darwin and Linux in system-cc-include

cc.el



And the code how to call it in use-cc

: sample-self-epilogue.el

0


source







All Articles