I want to setup a unit testing framework for a c project (c not c++). I have looked into
this list and checked out this stackoverflow question. I want a framework that I can easily setup for my project that only uses standard c libraries and is compiled and run on fedora 14 (64 bit version). It is not an embedded system like on the stackoverflow question. It looks like check and google test framework would work best. Do you guys know of any advantages/disadvantages of using one over the other or is their a better option out there? I have used JUnit and NUnit in the past for java and c# code. If it matters, I compile and run everything from the command line instead of using one of the IDEs.
... that only uses standard c libraries ...
Why is this requirement so important for the test framework if this is not an embedded system? I believe you can keep your production code c, while using any c++ framework.
If the requirement really is C only, I think it's pretty clear that you should go for Check.
If the requirement for C only is not for the test framework then I would go for Google Test, since, from what I have seen, it is offering more.
/Dan
Related
I'm sure this is documented somewhere but I'm struggling to find what I'm after. I am developing a project in C (and explicitly not C++), and having had good experiences developing Java projects with JUnit for TDD, I'd like to take a similar approach for this new project.
Can anyone provide a walkthrough for creating and running a simple C project, and running a couple of unit tests on them within Eclipse CDT? I have Eclipse CDT (Luna) and the unit-testing plugin as described in the frequently referenced blog. Most of the guidance appears to be for C++.
FWIW I'm running on Windows 7 and compiling with MinGW GCC.
Have you given google test a try? Its technically a c++ library, but has very little overhead to test your functions. A c++ test project would easily be able to consume the library generated from your c code, so should be pretty easy.
For example, this is what a test would look like
#include "gtest/gtest.h"
#include "MyProject/myFunc.h
TEST (myFuncTest, calculate) {
EXPECT_EQ (18.0, myFunc_calculate (324.0));
}
You can find more details at IBM Developerworks on YouTube etc.
After a lot of research, I tried most of the libraries for C and C++ testing and the one that was the right one for me was the Acutest.
I have created a public repository with an example that also uses Github Actions and a makefile in order to accomplish Continuous Integration (CI) by compiling the code and the tests and running them on every push automaticly.
Repository Link : CPP_Unit_Testing
I was wondering if i can create an application using C because android applications nowadays are programed using java and i don't have a lot of knowledge in Java programing
You can use something called the NDK to create statically linked libraries that Android can call. Remember these are linked libraries (.so files) and so they do not have a Main in the traditional sense. To find more information on that follow this link. http://developer.android.com/tools/sdk/ndk/index.html
It's important to note that you will still need to write some Java code but it allows you to do a lot of the non GUI work via C code.
On the flip side IOS programs are written in Objective-C which sounds similar to C but from what I've been told it's very far apart.
First of all, I'm new for this and I need a little help!
I have a LEGO Mindstorms EV3 robot, I downloaded (LEGO Mindstorms EV3 Home Edition) to control the EV3. Unfortunately, I couldn't find the source code for the EV3 in the mentioned software. So, please if anybody could tell me the name of the software that enables you to program EV3! I would be most appreciated!
I also downloaded (Bricxcc) software but it was an old version. I couldn't find a newer version which contains EV3.
Can I use C language to program EV3 ? Or to add some features to the sensors?
Note: I ended with leJOS software to program the code with java it is much easier and there are a lot of resources for the EV3 brick in java. Wish you all the best!
You can find the EV3 source code here: https://github.com/mindboards/ev3sources
The generated documentation from this source code is available here and here.
Bricxcc has some experimental support for EV3 but it is not being actively developed (since Oct. 2013). You can find the latest test version here. Searching the web for "bricxcc ev3" will come up with some tutorials (for example, the one at http://www.robotnav.com looks good).
ROBOTC is a good alternative, although it is not free.
There is also ev3dev. There is a C library for ev3dev here or you can write your own.
The EV3 runs on Linux w/ glibc, so you only need to upload your C programs. For C++ you need to copy over the C++ standard library. Programming like that is a bit inconvenient, as you have to mess directly with the device files.
The c4ev3 bundle streamlines this. It's built around an Eclipse Plugin that includes a GCC Toolchain, an API and an integrated Uploader and File browser usable right out of Eclipse.
C and C++ Hello World template projects are included.
API and Uploader are also usable separately from Eclipse, so you can use it however you like.
Check it out :-)
Disclosure: I wrote part of the software.
I'm trying to find an IDE for C that will give me the same level of comfort I got used to from programming in Java. I heard good things about Geany (from related questions here on Stack Overflow), and am familiar with Eclipse from my work with Java, and I was wondering which would be better suited for Linux development (kernel space stuff).
In particular I'm interested in an objective opinion of which one has a better (straightforward) integration with the terminal, and which one gets the closest to IDE features for OO languages like Java with the minimal amount of hassle. Any other relevant comparisons will be welcomed of course.
Use the Eclipse, Luke...
I supposed that I'd never give such advice, but Eclipse with CDT is a very good IDE, one of the most advanced. You should understand that Geany is only a text editor with some IDE features. And Eclipse is an IDE, yes - not so lightware like Geany, but it has lots of truly IDE features: refactoring, code analysis, error detection, and in-code hints. Also, it has easy integration with many popular profilers.
Simply try CDT - you'll like it.
The real question is: How much do you want your IDE to do for you? Eclipse will do much more than Geany, which can make you more productive, or can make it more fragile.
Eclipse will impose its own project structure, including putting metadata files in your directories. It will also require that it be able to successfully build your project(s) before many of its features will work, so you need to make sure that it can find all of your dependencies, etc. Basically, it may take more time & effort to get started. However, it has a ton of features.
Geany is much less intrusive, much faster startup, with excellent text-editing abilities - perhaps better text-editing than Eclipse - but a more modest set of programming tools. It works well when you want your builds to be external, eg launching 'make' or Maven.
I use Eclipse for launching automated tests, and for interactions with SVN (Geany has a plugin for Version Control integration, but it's limited & seems to be buggy). For most things, I prefer Geany.
I personally like Geany because it is so lightweight. But as Evgeny points out it is not a fully fledged IDE. Its built in terminal is a standard Linux shell (sh, no fancy bash here). If you don't need all the advanced features of Eclipse, Geany might be possible alternative, but if not, go with Eclipse.
Good day folks, I'm in a need of a bit of guidance.
Basically, I'm a webdev who knows some C from the past, but I've only developed somewhat simple console apps for *nix.
Shortly, I want to develop a simple Win program with a GUI and not get my hands into any of the following technologies:
.NET C#
Java
C++ (especially this one)
Because I have nor the time nor the need for it currently.
1). Can I use wxWidgets without resorting to cpp (if not, what other native looking and lightweight widget toolkit would you suggest?)
2). Can I use OpenCV with strict C? (no templates, inline functions, etc)
3). Should I look for other options for a compiler besides MinGW? Is Intel one worth investigating? (AFAIK, it has a restrictive license).
4). What IDE of the following would you suggest for windows / c programming
Dev-C++
Eclipse with appropriate plugins (can't remember the exact one)
Any text editor + *.bat for compiling??
Thanks!
If you're interested in learning C-based Windows programming directly, and not using other intermediate tools:
There's a really good reference book by Charles Petzold called Programming Windows. It's definitely the way to get started. Absolutely everything is crystal clear, and you never need C++.
The Windows API, as a whole, is built for C programmers. All the fancy stuff like an actual application window is passed back as "HANDLE"s, which are more-or-less just pointers into the OS's object table. You as a programmer never have to deal with objects, just their HANDLEs.
Also, this particular book does a good job describing the Windows event-loop. If you're unfamiliar with it, it is described in generous detail.
Good luck!
For C Windows GUI programming the easiest thing is VC++ (any version since 6.0) and The Charles Petzold Programming Windows book.
The free Express version of the Microsoft compiler should work fine - I'm not sure if you'd have to download the Platform SDK or if it comes with one.
You can write Windows GUI programs in straight C. Download the Windows SDK and look at the "GENERIC" sample (I assume it's still in there). This is pretty much the minimal code required for a Win32 app, and it's in plain-ol' C.
Edit: Hmmm, it doesn't appear to be installed on this laptop. You can find it online here.
It might be worth reconsidering C#.NET. You could easily learn C# in a couple days, and be developing slick apps very quickly. Straight C-based windows libraries, particularly Win32, are BRUTAL in comparison. You'd spend a week just to write a simple app that would take minutes in C#.
The only C-based toolkit I can think of is the Windows port of GTK+. I have no experience using it in the Windows environment though. It is very mature on the Linux side though, and may be good enough if your needs are simple.
Learning the Win32 API is hard! But like others have stated, Petzold's book is the way to go if you insist on going down that path.
My opinion is that developing a Windows GUI using only C and the Win32 API would be harder to learn than picking up just enough C++ to utilize one of the C++-based frameworks. You could still do the majority of your work in plain C.
As for free IDEs, I would go with Visual Studio 2008 Express Edition.
You don't need anything.
Just use C and Win32 api , like real programmers, not kids..
See the VS Win32 wizard
Regarding wxWidgets, you can use https://sourceforge.net/projects/wxc
I never actually heavily used it, so I'm not aware of its maturity.
Mingw and Microsoft Visual C++ are my favorite compilers. Remember you can always use strict C and compile it using a C++ compiler, since valid C is almost always valid C++.
For windows, I've used Dev-C++ in the past, but nowadays Microsoft Visual C++ seems a better solution.
If you're going for text editor+bat, check out Notepad++.
EDIT: Just to clarify, using Microsoft Visual C++ does NOT mean learning C++. You can use C in it perfectly because - I repeat - valid C is often valid C++. Don't want C++? No problem. Just stay away from the C++-only features and you're still safe in a C++ compiler.
EDIT: Roger Lipscombe has noted in the comments that a pure C compiler is available in Microsoft's Visual C, using the /TC switch.