I am trying to create an stdafx.cpp file that includes all the #imports in a project to improve build time. I want to include all the imports for word/excel/ppt of office 2010, 2013 and 2016.
When I place all the imports in the CPP, there is no problem but when I place all the #imports in the stdafx.cpp. cx_excel2013.tlh is generated incorrectly.
The problem is that cx_excel2013.tlh is trying to use "Office2010" namespace for objects in "Office2013", which causes the build to fail.
for example, enum Office2010::MsoTriState LinkToFile is being generated which fails the build.
Can anyone explain what is going on or what is happening and how to overcome this (without returning the #imports back to the CPP)???
Also, I thought of just generating the TLH/TLI and remove the imports all together because they will not change, but it feels wrong and I don't solve the real problem.
Thanks!
STDAFX.CPP:
// Office 2010
#import "..\lib\tlb\office\MSO2010.tlb" rename_namespace("Office2010") rename("RGB","msoRGB") rename("SearchPath", "msoSearchPath") rename("DocumentProperties", "msoDocumentProperties")
#import "..\lib\tlb\office\VBE6EXT2010.tlb" rename_namespace("VBE6EXT2010") rename("Property", "vbeProperty")
#pragma warning(disable: 4192)
#import "..\lib\tlb\office\excel2010.tlb" rename_namespace("Excel2010") rename("VBE6", "VBE6EXT2010") rename("RGB","excelRGB") rename("DialogBox","excelDialogBox") rename("CopyFile","excelCopyFile") rename("ReplaceText","excelReplaceText") rename("Property", "excelProperty") no_function_mapping
#import "..\lib\tlb\office\msppt2010.tlb" rename_namespace("PowerPoint2010") rename("VBE6", "VBE6EXT2010") rename("RGB","pptRGB") rename("Property", "pptProperty") no_function_mapping
#import "..\lib\tlb\office\MSWORD2010.tlb" rename_namespace("Word2010") rename("VBE6", "VBE6EXT2010") rename("ExitWindows","wordExitWindows") rename("FindText","FindText1") rename("RGB", "wordRGB") no_function_mapping
#pragma warning(default: 4192)
// Office 2013
#import "..\lib\tlb\office\MSO2013.tlb" rename_namespace("Office2013") rename("RGB","msoRGB") rename("SearchPath", "msoSearchPath") rename("DocumentProperties", "msoDocumentProperties")
#import "..\lib\tlb\office\VBE6EXT2013.tlb" rename_namespace("VBE6EXT2013") rename("Property", "vbeProperty")
#pragma warning(disable: 4192)
#import "..\lib\tlb\office\excel2013.tlb" rename_namespace("Excel2013") rename("VBE6", "VBE6EXT2013") rename("RGB","excelRGB") rename("DialogBox","excelDialogBox") rename("CopyFile","excelCopyFile") rename("ReplaceText","excelReplaceText") rename("Property", "excelProperty") no_function_mapping
#import "..\lib\tlb\office\msppt2013.tlb" rename_namespace("PowerPoint2013") rename("VBE6", "VBE6EXT2013") rename("RGB","pptRGB") rename("Property", "pptProperty") no_function_mapping
#import "..\lib\tlb\office\MSWORD2013.tlb" rename_namespace("Word2013") rename("VBE6", "VBE6EXT2013") rename("ExitWindows","wordExitWindows") rename("FindText","FindText1") rename("RGB", "wordRGB") no_function_mapping
#pragma warning(default: 4192)
// Office 2016
#import "..\lib\tlb\office\MSO2016.tlb" rename_namespace("Office2016") rename("RGB","msoRGB") rename("SearchPath", "msoSearchPath") rename("DocumentProperties", "msoDocumentProperties")
#import "..\lib\tlb\office\VBE6EXT2016.tlb" rename_namespace("VBE6EXT2016") rename("Property", "vbeProperty")
#pragma warning(disable: 4192)
#import "..\lib\tlb\office\excel2016.tlb" rename_namespace("Excel2016") rename("VBE6", "VBE6EXT2016") rename("RGB","excelRGB") rename("DialogBox","excelDialogBox") rename("CopyFile","excelCopyFile") rename("ReplaceText","excelReplaceText") rename("Property", "excelProperty") no_function_mapping
#import "..\lib\tlb\office\msppt2016.tlb" rename_namespace("PowerPoint2016") rename("VBE6", "VBE6EXT2016") rename("RGB","pptRGB") rename("Property", "pptProperty") no_function_mapping
#import "..\lib\tlb\office\MSWORD2016.tlb" rename_namespace("Word2016") rename("VBE6", "VBE6EXT2016") rename("ExitWindows","wordExitWindows") rename("FindText","FindText1") rename("RGB", "wordRGB") no_function_mapping
#pragma warning(default: 4192)
EDIT:
I should add that the build fails and the other TLH/TLIs are not being generated.
The problem was that all office versions are using the same GUID, the only difference is the version, which the #import directive ignores.
That is why while constructing Excel2013.tlh/tli is using Office2010 (the first office TLB), because the GUID is it looking for is already defined so it can ignore Office2013. From VS point of view, it is the same one.
The interfaces are backward compatible, so the solution was just importing the 2016. The downside is that Office2010/2013 code can try to use code that it doesn't really support (fails in runtime).
Related
All of a sudden, I'm getting "Expected unqualified-id" and "Type name declared as a reference to a reference" parsing issues from importing opencv2/opencv.hpp I tried relinking opencv3, upgraded from opencv 3 to 4 and restarted Xcode. How can this be resolved?
Used prebuilt opencv from here: https://opencv.org/releases/ and Xcode 10.2
See All Parsing Errors
Expected unqualified-id:
CODE - Removed everything and left with this, but it still has parsing errors.
-------
.mm
------
#import <opencv2/opencv.hpp>
#import <opencv2/imgcodecs/ios.h>
#import <Foundation/Foundation.h>
#import "OpenCVWrapper3.h"
#include <vector>
using namespace std;
#implementation OpenCVWrapper3
+ (NSString *) openCVVersionString
{
return [NSString stringWithFormat:#"OpenCV Version %s", CV_VERSION];
}
#end
----
.h
----
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#interface OpenCVWrapper3 : NSObject
+ (NSString *) openCVVersionString;
#end
Ok so... I don't have a clue what caused the error. I opened another ios project that uses opencv and it gave the same errors. Then I created a new project and added #include iostream, ostream and got the same error. So its was not isolated to opencv. So I deleted and reinstalled Xcode and now it works!! Bizarre!
I want to use the Code Analysis in Visual Studio 2017 but I'm using Qt and it gives me a lot of warnings from the headers. I've tried turning off warnings:
#pragma warning(push, 0)
#include <QtGlobal>
#pragma warning(pop)
but it doesn't help. I also tried using this:
#include <codeanalysis\warnings.h>
#pragma warning(push, 0)
#pragma warning(disable : ALL_CODE_ANALYSIS_WARNINGS)
#include <QtGlobal>
#pragma warning(pop)
but no help. How can I disable the Code Analysis for the Qt external headers?
If you open your .vcxproj file, down the bottom you should see:
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
below this you can add:
<PropertyGroup Condition="'$(Language)'=='C++'">
<IncludePath>$(QTDIR)\include;.\GeneratedFiles;$(IncludePath)</IncludePath>
<CAExcludePath>$(QTDIR)\include;.\GeneratedFiles;$(CAExcludePath)</CAExcludePath>
</PropertyGroup>
Microsoft say there's a bug where CAExcludePath is overwritten by IncludePath but this is fixed in Visual Studio 2017 V15.3 and you'll only need to set CAExcludePath - I haven't verified this (I'll update this once I do).
This answer came from How can I suppress warnings for external headers in VS2017 Code Analysis?
I am trying to use one of my Objective-C class from another target, in my Swift class inside extension target.
I created the <Project-Name>-Bridging-Header.h and included that objective-c file, but the build is not compiling because of build error in "Cryptor.h" and <CommonCrypto/CommonDigest.h>. I believe this has to do something with CommonCrypto framework.
This is how my Bridging-Header.h looks:
#import <UIKit/UIKit.h>
#import <FacebookSDK/FacebookSDK.h>
#import <GooglePlus/GooglePlus.h>
#import <Security/Security.h>
#import <CommonCrypto/CommonCrypto.h>
#import <CommonCrypto/CommonDigest.h>
I guess this is due to Common Crypto library. Has anybody encountered the same issue and solved it?
EDIT:
Specifically, i am getting build error - "Missing #end" in CommonDigest.h and because CommonDigest.h is not getting build hence the error in Cryptor.h.
I don't know if it will fix your problem, but the bridge-header is sometimes a bit buggy. At least it was the case for me.
Try to edit your header and import your files like that:
#import "FacebookSDK.h"
#import "GooglePlus.h"
#import "Security.h"
#import "CommonCrypto.h"
#import "CommonDigest.h"
I have removed the UIKit-header, because you don't really need it, because swift has it's own UIKit.
I asked a similar question yesterday because of the amount of time Compass was taking to watch and compile my Sass files.
So, I pose this question. What is the ideal way to use a framework like Foundation 5, and still have the ability to update it in the future, while using Hammer for Mac for compiling and optimising my stylesheets and allows me to use the Bourbon mixins instead of Compass.
Any help is appreciated. Thanks in advance!
If you want to update Foundation in the future without any problems, you should follow rule: don't change files in foundation/components directory
all variables, that you need, you can find in foundation/settings.
some example of app.scss:
#import "bourbon";
#import "settings"; //where you can change all variables
#import "foundation"; //better
settings file look like:
https://github.com/zurb/foundation/blob/master/scss/foundation/_settings.scss
I arrange my styles as follows to ensure a clear separation:
styles/
app.scss
_settings.scss
external/
_bourbon.scss
_foundation5.scss
My externals folder above does not contain vendor CSS but is instead used for (selectively) importing vendor CSS located elsewhere in my project by using a sass load path.
I currently fetch vendor CSS using bower, therefore all my CSS lives in a bower_components/ folder at the root of my project. This way I can easily update to newer versions and there is a clear separation from what is vendor source and what is specific to my project.
I found I also had to resolve a few conflicts with bourbon and foundation as follows. I am currently using Bourbon 3.1.8 but experimented briefly with 3.2 (which doesn't yet compile with he current sass toolchain) hence the commented out lines specific to Bourbon 3.2:
// external/_bourbon.scss
// we comment out things that conflict with foundation styles
//#import "bower-bourbon/settings/prefixer"; // 3.2+ only
//#import "settings/px-to-em"; // 3.2+ only
// Custom Helpers
#import "bower-bourbon/helpers/deprecated-webkit-gradient"; // 3.1.8 only
#import "bower-bourbon/helpers/gradient-positions-parser";
#import "bower-bourbon/helpers/linear-positions-parser";
#import "bower-bourbon/helpers/radial-arg-parser";
#import "bower-bourbon/helpers/radial-positions-parser";
#import "bower-bourbon/helpers/render-gradients";
#import "bower-bourbon/helpers/shape-size-stripper";
// Custom Functions
//#import "bower-bourbon/functions/assin"; // 3.2+ only
#import "bower-bourbon/functions/compact"; // 3.1.8 only
//#import "bower-bourbon/functions/flex-grid"; // foundation conflict
//#import "bower-bourbon/functions/grid-width"; // foundation conflict
#import "bower-bourbon/functions/linear-gradient";
#import "bower-bourbon/functions/modular-scale";
#import "bower-bourbon/functions/px-to-em";
#import "bower-bourbon/functions/radial-gradient";
//#import "bower-bourbon/functions/strip-units"; // 3.2+ only
#import "bower-bourbon/functions/tint-shade";
#import "bower-bourbon/functions/transition-property-name";
//#import "bower-bourbon/functions/unpack"; // 3.2+ only
// CSS3 Mixins
#import "bower-bourbon/css3/animation";
#import "bower-bourbon/css3/appearance";
#import "bower-bourbon/css3/backface-visibility";
#import "bower-bourbon/css3/background";
#import "bower-bourbon/css3/background-image";
#import "bower-bourbon/css3/border-image";
#import "bower-bourbon/css3/border-radius";
//#import "bower-bourbon/css3/box-sizing"; // foundation conflict
//#import "bower-bourbon/css3/calc"; // 3.2+ only
//#import "bower-bourbon/css3/columns"; // foundation conflict
#import "bower-bourbon/css3/flex-box";
#import "bower-bourbon/css3/font-face";
//#import "bower-bourbon/css3/hyphens"; // 3.2+ only
#import "bower-bourbon/css3/hidpi-media-query";
#import "bower-bourbon/css3/image-rendering";
#import "bower-bourbon/css3/inline-block";
#import "bower-bourbon/css3/keyframes";
#import "bower-bourbon/css3/linear-gradient";
#import "bower-bourbon/css3/perspective";
#import "bower-bourbon/css3/radial-gradient";
#import "bower-bourbon/css3/transform";
#import "bower-bourbon/css3/transition";
#import "bower-bourbon/css3/user-select";
#import "bower-bourbon/css3/placeholder";
// Addons & other mixins
//#import "bower-bourbon/addons/button"; // foundation conflict
//#import "bower-bourbon/addons/clearfix"; // foundation conflict
#import "bower-bourbon/addons/font-family";
#import "bower-bourbon/addons/hide-text";
//#import "bower-bourbon/addons/directional-values"; // 3.2+ only
//#import "bower-bourbon/addons/ellipsis"; // 3.2+ only
#import "bower-bourbon/addons/html5-input-types";
#import "bower-bourbon/addons/position";
#import "bower-bourbon/addons/prefixer";
//#import "bower-bourbon/addons/rem"; // 3.2+ only
#import "bower-bourbon/addons/retina-image";
#import "bower-bourbon/addons/size";
#import "bower-bourbon/addons/timing-functions";
//#import "bower-bourbon/addons/triangle"; // foundation conflict
// Soon to be deprecated Mixins
#import "bower-bourbon/bourbon-deprecated-upcoming";
Importing foundation is just a one-liner currently but you could tweak it to only source what you need from foundation:
// external/_foundation5.scss
#import 'foundation/scss/foundation';
Why would a #define statement in a .pch not be recognized by .mm files?
Results in "use of undeclared identifier" and "not declared in this scope" when attempting to reference the macro.
Pch looks like this:
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iPhone SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
#ifdef DEBUG
#define dNSLog(...) NSLog(#"%s %#", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
#else
#define dNSLog(format, ...)
#endif
I had the same problem, cleaning was not solving it.
After closing and restarting Xcode 4 everything was fine.
If that can help someone...
Turns out Xcode 4 wasn't actually cleaning the build. :(