Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Mix C/C++ environment

Mix C/C++ environment

Mix C/C++ environment


I am developing a verification environtmnet to verify a HW block.

Test bench will be written in C and it will call C++ functions. this C testbench will be wrapped around C++ wrapper and this wrapper get called from HDL duirng Mix HDL/C/C++ verifcation environtment.

Calling C from C++ ok but can we do the reverse?

I am new to C and C++



RE: Mix C/C++ environment

You can't call C++ from C easily.  You may be able to get at the routine using the mangled name but I've never done it.

Having said that, there is no point in differentiating between C and C++ as it will lead to no end of problems.  Just build everything with the C++ compiler and treat everything as C++ code.  There are some minor code incompatibilities between the two eg

extern void abc();

In C means "I don't know what the parameters to abc are" and in C++ means "abc has no parameters".  Also, C++ doesn't like the old C style declarations.

void abc(def, ghi)
float def;

has to be

void abc(float def, int ghi)

Basically, declare all your prototypes and all the parameters.  The only other problems are reserved words in C++ like this and template.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close