I want to develop using C & C++ using XCode 5. I particularly like the integration of XCTest and Xcode and the CI capability that you get by using OSX Server. I want to have a mocking framework, and ideally one where the mocks are automatically generated, as this seems most likely to ensure that the mocks follow a standard format (and themselves are not going to have errors).
Q1. I can't see how OCMock can work for mocking C & C++: is this possible?
Q2. CMock seems to be great, but it relies on Unity. Is it possible to integrate CMock into XCTest?
Q3. Does anyone have any other suggestions please?
Q1. OCMock can only mock methods on Objective-C classes, objects, and protocols.
Q2. What is Unity? (And I'm asking this as the maintainer of OCMock...)
Q3. There are several options for C and C++, I don't have much experience, never mind a strong recommendation.
Related
So I'm currently working with a proprietary programming language that is C-like. So while this question wasn't directly inspired by a C program, I think those of you who are familiar with C may be able to offer some good insight.
I'm currently working on a library. This library encompasses some basic features as well as features that require other libraries. I'm running into the problem of 'where do I draw the line for how many dependencies are included in this library?'.
So this seems like it could be a fairly common problem. What methods exist for addressing this issue?
Something I've had in mind. Implement #defines and #ifdefs that allow users to compile the library with only the features they want. So essentially, all of the library functions that require additional libraries would be wrapped in #ifdef guards. The user would be responsible for #define'ing the features they want. Essentially, this method would allow a user to still use parts of the library without needing to have other dependent libraries.
Your thoughts? Again, this is for a C-like language. Thus tools like CMake, etc. aren't available.
Yes. If you take a look at the Linux kernel for instance, it's done the exact same way.
Yes you can and You Should.
I use them whenever i feel the necessity. Also, i have been working on freeRTOS and that's how things are being done over there.
I'm starting to wonder what is the best way to work with a moderately sized AngularJS project. I'm wanting to find where a directive or service is used without having to do a 'Ctrl+F' and search the project manually. Are there any IDEs that offer this feature, or does anyone have some approaches for working with these projects that they could share?
I didn't try it personally, so my answer is going to be pretty short, but I think you should look at TypeScript (http://www.typescriptlang.org/). I've seen many mentions of it being a good fit for Angular, and it allows for "Intellisense" features in IDE that should meet your needs.
Basically it means rewriting your code in an "augmented" version of JavaScript that makes your code typed and therefore should make it easier to handle a large codebase and run static analysis.
Here's some information about TypeScript support in IntelliJ, if that's your IDE: https://www.jetbrains.com/idea/help/typescript-support.html
Any suggestion for template base code generator for C / C++ specifically to generate repetitive code generation? (Not UML / MATLAB model based or other advanced stuff). For a newbie in this field any good generic tutorial (not tool based)?
I came across GNU Autogen looks good but looks like it needs a steep learning curve. I would prefer some plug-in for eclipse like IDE, easy to use and most importantly good tutorials.
The basic concept of code generation is simple enough - and people's needs are varied enough - that there are quite a few options out there.
Boost.Preprocessor is a library of functions built on top of the standard C / C++ preprocessor that makes it much easier to use the preprocessor to do code generation. It's not as flexible as other options, and figuring out preprocessor errors can be tricky, but the fact that it uses only standard language features greatly simplifies using it and integrating it into your builds.
If you know Python, there's Cog.
Some of Google's projects use Pump.
There are many general-purpose templating solutions (Python's Genshi, eRuby, etc.). These are often designed for generating HTML and XML but also work for code.
It's also easy enough to hack something together in the scripting language of your choice.
Without knowing more about what your needs are and what tools you're comfortable with, I can't give a more specific recommendation.
I'm not familiar with anything that provides an Eclipse plugin.
If you know Python, then Cog could be considered as light-weight solution: http://www.python.org/about/success/cog/
Look at my answer for a similar question for Java classes using M2T-JET, an eclipse based, lightweight templating generator. JET is language agnostic and you can see from the example that it's fairly easy to use.
I appreciate using Lua for this task, with something like Templet or one of another myriad of Lua-based preprocessors. The benefit of using Lua over something like Python is that you can, if necessary, include the source code to your template processor and a basic Lua installation along with whatever it is you are shipping. You may then add the compilation of Lua and subsequent template files to the build process as usual.
I would advise not using Python-based solutions for one reason: juggling various pythons to satisfy every developer's use of a completely different yet incompatible version is annoying. If you choose to use a language which you can't embed in your trees, you'll want to make sure pre-computed versions are available.
Late to the party but I would recommend Codeworker Its the only tool I found that does everything the above tools do and more. It has the Python Cog like functionality for embedded generation, it has the template based generation like Templet or Pump. And it has the rather useful feature of protected areas so you can customise your code as needed and re-generate.
I have used it for generating all the boiler plate c++ code as well as configuration for projects like SQL, config, javascript etc.
I'm developing a fairly simple C project for an embedded device. I'd like to employ xUnit testing. I've settled down with the Check framework (http://check.sourceforge.net/), but it seems it doesn't support function stubs. I remember using a very syntactically similar framework a few years ago that supported stubs, but i can't remember its name.
So, can anyone suggest an xUnit framework for C that supports stubs? A way to imitate stubs while using Check library would be OK, too.
Cgreen supports mock functions, is this what you want?
https://cgreen-devs.github.io/#_what_are_mock_functions
I have a library written in C that I would like to use in an Objective-C app, either on the Mac or the iPhone.
Unfortunately, since this library is being written by individuals in the open source space, the documentation is quite sparse and incomplete. While I can figure out how to use the stuff in the library, I don't really have an overview of the entire code base.
What I would like to do is wrap the library up into some easily usable and transferrable classes in Objective-C.
Does anyone have any tips on how to approach this?
Any advice on the best way to get a visual hierarchy of how the library is structured?
How would I go about deciding how to best structure the wrapper for reusability and ease of use?
Any and all help will be greatly appreciated, thanks!
I've done this a few times myself. This can be fun -- it's your chance to fix (or at least hide) bad code!
You can use Doxygen to get a visual hierarchy of the code (although I've only used it for C++ libraries, it also works with C), or any of the other free tools out there.
Don't structure your wrapper class like the underlying library if the library isn't designed or documented well. This is your chance to consider the point of view of the user and how they are going to be using the code. Write your test cases first to figure that out, and/or talk to some people who use the library already.
Two nice design patterns that match up with what you're doing are Adapter and Facade.
First, remember: a C library is an Objective-C library. You don't actually need to do any wrapping at all, although you may want to if the library interface is especially cumbersome.
Second, if you decide that you want to write a library wrapper, keep it simple. Identify the core functions of the library that you actually plan to use, and think about how best to provide an interface to those functions and those functions only, with your intended usage in mind. Design an interface that you want to work with, then implement it over the library.
Since ARC (Automatic Reference Counting) was added to the Apple compilers and libraries, Objective-C and C are no longer so freely interchangeable. (Here's a list of ARC documentation and tutorials.) You need to consider the memory allocation issues much more thoroughly, and you might just want to "bridge" the libraries. See this SO question and some of the links from there, about how Apple bridges between Obj-C and C libraries.