I am a newbie for Clang-Format.
I use ./bin/clang-format -style=google -dump-config > .clang-format as my base .clang-format.
Based on that, I changed some parameters for my customized demands.
However, after I change the column_limits from 80 to 0(I just want break the lines using my personal decision), all my #include "header.h" become:
#include \
"header.h"
It's weird. I have be struggling with this for a whole day. But the problem is still in there.
By the way, all my #include do not have this problem
Could anyone give me some clue about this?
This was a bug that has been fixed by now. Use a more recent version and this problem will go away.
Related
I'm using C++Builder. I want to include a header file that is located in a separate folder from my project.
I tried to add the folder to the search path, and include the file in my project:
#include "GXWARE32\Include\gxutils.h"
but when I compile I have some errors in the file included
So, I tried to add all subfolders to the search path, and it works with a small folder but not with a big one.
According to the error log, maybe you missed some header file that gxutils.h relies on.
Without code, we can only guess... some libs need a specific #include order... some libs have hard-coded relative paths and by moving them you broke that... Some libs also need configuration macros defined before #include.
From the errors, you have #include'd some file more than once (and it's not protected by a header guard, like #pragma once or #ifndef file_id #define file_id ... #endif macros) and you are missing a previous #include for some datatype used.
Open the gxutils.h file and look around line 143 for the missing datatype. In the IDE, during compilation the cursor usually stops on the stuff directly. Then just search the files in your lib for the datatype, so you know what file to #include before...
All of these might happen sometimes if you include the wrong file... some libs need to include cpp instead of h...
Adding search paths will not do anything as the compiler is not complaining about files not found...
I'm developing a C/C++ library that uses ImageMagick (using/supporting both libMagickCore and libMagick++), for reading and writing image data (not for processing).
Now, I would also like to support IM's GraphicsMagick fork (e.g. using Debian's graphicsmagick-libmagick-dev-compat package).
Unfortunately, the APIs have diverged enough, so that I cannot use one as a drop-in replacement of the other. Since they are still quite similar, I plan to use a number of #ifdefs for the API specific parts.
Now my problem is, that it seems quite complicated to detect which API is actually used via pre-processor directives, right after including the generic header (which is called the same for both variants).
Basically, I'm looking for something like a #define (provided by the IM/GM headers) that can be used to tell the two APIs apart. Something like:
#include <Magick++.h>
#ifdef GRAPHICSMAGIC_DEFINE
// GM-specific code
#else
// IM-specific code
#endif
or, for the C-API:
#include <magick/MagickCore.h>
#ifdef GRAPHICSMAGIC_DEFINE2
/* GM-specific code */
#else
/* IM-specific code */
#endif
Ideas?
Autoconf, or CMake.
Really - there's no simpler way around it, but you need to package your solution with something that will ask the system what library is present, and will then generate config.h with the correct pre-processor definitions.
The difference between GraphicsMagick & ImageMagick seem simple enough to do something clever, BUT now that we're a year into the release of IM 7, we now need to check which version & adjust definitions as needed. For example
// IM 6
#include <magick/MagickCore.h>
// IM 7
#include <MagickCore/MagickCore.h>
I would suggest reviewing existing m4 scripts used by other projects available online.
So back to the original question, the generic include headers my look something like this... (and I quote from Imagick library, but can be expanded to cover GM)
#if defined (IM_MAGICKWAND_HEADER_STYLE_SEVEN)
# include <MagickWand/MagickWand.h>
#elif defined (IM_MAGICKWAND_HEADER_STYLE_OLD)
# include <wand/magick-wand.h>
#else
# include <wand/MagickWand.h>
#endif
I have a library that uses the mysql library (libmysqlclient) on linux that I'm porting to windows, but I seem to run into a "problem" with where the header files are located. Under linux the headers are located under /usr/include/mysql (at least for Debian) so with standard include path they would be included as:
#include <mysql/mysql.h>
However when installed the library under windows the main header seem to be located at c:\Program Files\MySQL\MySQL Connector C 6.1\include\mysql.h which would require it to be included as:
#include <mysql.h>
I need to build it for iOS as well, but at this moment I don't know where the header files will be located there.
What is the normal way to solve this? Should I add /usr/include/mysql to the include path under linux? Wouldn't that open up for higher probability of header name collisions?
You can determine which platform you're running on by checking for a predefined symbol. There are a few lists of such macros floating around; here's one:
http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system
Then, you can #include a different path depending on the platform:
#if defined(_WIN32) || defined(_WIN64)
# include <mysql.h>
#elif defined(__linux)
# include <mysql/mysql.h>
#elif defined(__APPLE__)
# include <whatever path works on iOS>
#else
# error Unrecognized platform.
#endif
If you need to do this in more than one place, then put it into one of your own include files, and #include that, which will then #include the correct mysql.h in turn.
The other option, as you've already suggested, is to set your include path on each platform so that #include <mysql.h> works. Which one you use is a matter of taste.
According to the manual YY_BUF_SIZE is 16K and we need to override it. However, the manual does not specify how to override it, nor could I find any command line option for this. Can someone please indicate how to change this. In the generated source YY_BUF_SIZE is defined as follows:
#ifndef YY_BUF_SIZE
#define YY_BUF_SIZE 16384
#endif
so there may be a way to override it before this.
In your own code, simply #define YY_BUF_SIZE to whatever value you want. As long as you compile your code so the compiler sees your definition first, the #ifndef guard will prevent the default value from being set.
Using -DYY_BUF_SIZE=99999 (for whatever number, of course) on the command line is the only way to completely override the value, it seems to me.
The built-in flex skeleton/preamble precedes any %{...%} code given in the first (definitions) section of the .l source, and the skeleton is where the #ifndef YY_BUF_SIZE is. Therefore, to override within the .l file, it's best (to avoid possible warnings, etc.) to do
#undef YY_BUF_SIZE
#define YY_BUF_SIZE 99999
The potential pitfall of doing the override this way is that the skeleton also has the line
#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
and therefore that value will not be affected by the redefinition. In my case that did not matter, but it's something to be aware of.
Unfortunately there is no way, as far as I know, to insert code before the built-in preamble. If there is, I'dbe grateful to learn.
I am using bourbon and neat gems for create the design of a rails application. My application.css.scss contains this:
#import "bourbon";
#import "neat";
#import "main";
But if I run 'rake assets:precompile' then happens this error:
rake aborted!
Undefined mixin 'outer-container'.
(in /Users/anonymous/example/app/assets/stylesheets/admin/main.css.scss)
/Users/anonymous/example/app/assets/stylesheets/admin/main.css.scss:5:in `outer-container'
/Users/anonymous/example/app/assets/stylesheets/admin/main.css.scss:5
The file main.css.scss contains this:
footer#page_footer {
#include outer-container;
nav{
#include span-columns(6);
#include shift(3);
section#about_me_footer, section#contact_footer, section#miscellaneous_footer {
#include span-columns(2 of 6);
}
}
p {
#include span-columns(6);
#include shift(3);
}
}
Someone can give me some suggestions?
I was having the same problem. I was able to get it working in two different ways.
The first way is probably less desirable but you can add your code right in the application.css.scss file:
div.container {
#include outer-container;
}
Alternatively, you can add:
#import "bourbon";
#import "neat";
To the top of your main.css.scss file.
This allows you to keep your styles organized.
The bourbon site links to a page in their wiki regarding this problem, but the solution mentioned didn't work for me:
https://github.com/thoughtbot/bourbon/wiki/Rails-Help-%5C-Undefined-mixin
I had this same problem. The solution for me was to rename a partial file from layout.css.scss to _layout.css.scss. Any files making use of SASS mixins need to be included after those mixins are loaded in. In this case it was trying to precompile the layout.css file alone, though it did not require the source of the mixins it was referencing. Adding the underscore makes the precompiler ignore that file until another file requires it.
According to the Change Log the outer-container mixin has been removed as of version 2.0.0. The highest version you can use with outer-container is 1.8.0. When adding Neat via Bundler, you will get 2.0 or higher unless you specify a version in your Gemfile.
The new way to do this looks much simpler, but that's little comfort if you have a bunch of unsupported scss.
FWIW this is the issue reported https://github.com/thoughtbot/bourbon/issues/120, Using jacklin's comment about adding the import statements directly to my main css file resolved it. However, I'd like to have this problem fixed since I dont really want to keep adding those import statements to each file I wish to use the mixins for
I have had the same problem.
I had a div using #include outer-container, and a second div containing #include span-columns(8). The second div incorrectly sat outside the first, producing the misleading error "Undefined mixin 'outer-container'". Moving the second div inside the first (within the outer-container - in the CSS and HTML) corrected the problem.
For the problem above, you must do the same thing by making sure the p tag is a child of the footer.