473,395 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

typdef problem with C source files in VS 2010

4
Hi all,

I've got a VS 2010 project that makes some pretty standard typedefs like:

Expand|Select|Wrap|Line Numbers
  1. typedef int mlInt;
... and a function that looks like:
Expand|Select|Wrap|Line Numbers
  1. void mlVecMult(int length, int* vec1, int* vec2, int* vecOut);
In my .c file (vector.c), I have a basic implementation:
Expand|Select|Wrap|Line Numbers
  1. void mlVecMult(mlInt length, mlInt* vec1, mlInt* vec2, mlInt* vecOut)
  2. {
  3.     for(mlInt i=0; i < length; i++)
  4.     {
  5.         vecOut[i] = vec1[i] * vec2[i];
  6.     }
  7. }
So when I compile this, the compiler gives a ton of errors like:

ml_vector.c(5): error C2143: syntax error : missing ';' before 'type'

.. so it doesn't find the type properly. BUT if I change the extension of the file vector.c to .cpp, it works fine.

Is this some C syntax thing I'm forgetting? Thanks for any help.
Dec 17 '10 #1

✓ answered by donbock

You define variable i within the for statement in function mlVecMult. You couldn't do that in C until C99.
  • Move the definition to a line of its own prior to the for statement.
  • Investigate whether you need to set some command line switch or VS 2010 option to select C99.

2 1753
donbock
2,426 Expert 2GB
You define variable i within the for statement in function mlVecMult. You couldn't do that in C until C99.
  • Move the definition to a line of its own prior to the for statement.
  • Investigate whether you need to set some command line switch or VS 2010 option to select C99.
Dec 17 '10 #2
akevan
4
Of course... that's standard C. Thanks!! Taking a while to remember all these little differences between ANSI C and C++.
Dec 17 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sean Dettrick | last post by:
I am wondering if it is possible to increment an integer at compile time using template<int N> (or by any other method, e.g. compiler directives etc), across multiple source files. This may...
0
by: Matthias Martetschlaeger | last post by:
Hi everyone, we use Clearcase dynamic Views to get our Source-Files. Due speed reasons, the output files should not go to the same location (dynamic view) as the source files are located, this...
2
by: dbrans | last post by:
Hi There, Somehow the visual studio debugger is getting confused about which source files belong to which object files. For example, I'll set a breakpoint on line 92 in once source file, but...
0
by: sludgenz | last post by:
We've been having a great deal of problems getting our pdb files linking back to our source files when doing post-mortem debugging. I know this is possible because I've seen it done. At the moment...
5
by: Egbert Nierop \(MVP for IIS\) | last post by:
hi, I have a testing win2003 machine, where I debug inside a MMC process using a DebugBreak() statement. But only the first time, source code was shown, after that, I only get to see...
3
by: Jackie | last post by:
Hi all, I am new to visual c++, and found that each C++ project automatically generates source files and resource files, what are their roles, respectively? Thanks a lot.
0
by: tommaso.gastaldi | last post by:
I have a solution with 1 project on which I am working on say Pr1 I have another solution with another project, say Pr2. Source file in the existing Pr2 are organized within several nested...
4
by: Horacius ReX | last post by:
Hi, I have a C program split into different source files. I am trying a new compiler and for some reason it only accepts a single source file. So I need to "mix" all my different C source files...
0
by: Sells, Fred | last post by:
the short answer is a file is a module; therefore to 'include' access to 'myclass' in file xyz.py from another file called 'abc.py' you would put this in abc.py import xyz #note no '.py' x =...
6
by: Oliver Graeser | last post by:
Ok, stupid question.... I used to write programs all into one text files and compile them. Works, fine. Then I discovered XCode (or IDEs in general) which appear to be really increasing my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.