New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMock generates invalid C for headers with dashes in the name #3

Closed
malsyned opened this Issue Jul 28, 2012 · 4 comments

Comments

Projects
None yet
3 participants
@malsyned

malsyned commented Jul 28, 2012

When I gave CMock a header file named cmock-bug.h with the contents:

#ifndef CMOCK_BUG_H
#define CMOCK_BUG_H

void cmock_bug(void);

#endif /* !CMOCK_BUG_H */

It created this Mockcmock-bug.h:

#ifndef _MOCKCMOCK-BUG_H
#define _MOCKCMOCK-BUG_H

#include "cmock-bug.h"

void Mockcmock-bug_Init(void);
void Mockcmock-bug_Destroy(void);
void Mockcmock-bug_Verify(void);

#define cmock_bug_Expect() cmock_bug_CMockExpect(__LINE__)
void cmock_bug_CMockExpect(UNITY_LINE_TYPE cmock_line);

#endif

This mock header file won't compile because of the dashes in the guard macro and function names.

Dashes are pretty common in C file names, particularly in GNU and Gnome source code. This seems like a use case CMock would want to support.

@malsyned

This comment has been minimized.

Show comment
Hide comment
@malsyned

malsyned Jul 28, 2012

Actually, it looks like cmock requires the header file name to be a valid C identifier.

malsyned commented Jul 28, 2012

Actually, it looks like cmock requires the header file name to be a valid C identifier.

@barneywilliams

This comment has been minimized.

Show comment
Hide comment
@barneywilliams

barneywilliams Jul 29, 2012

Member

I believe the issue is that the regular expression we are using simply isn't allowing '-' as a valid header file name, though it definitely should.

We will add this to the list.

Thanks,
Greg

Member

barneywilliams commented Jul 29, 2012

I believe the issue is that the regular expression we are using simply isn't allowing '-' as a valid header file name, though it definitely should.

We will add this to the list.

Thanks,
Greg

@malsyned

This comment has been minimized.

Show comment
Hide comment
@malsyned

malsyned commented Jul 29, 2012

Here's a patch that fixes the issue for me:

http://malsyned.net/files/patches/cmock-sanitize-identifiers.patch

@sw17ch

This comment has been minimized.

Show comment
Hide comment
@sw17ch

sw17ch Oct 17, 2012

Contributor

@malsyned Could you recreate this patch as a pull request?

Contributor

sw17ch commented Oct 17, 2012

@malsyned Could you recreate this patch as a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment