Skip to content
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

c2v wrap sql.h encountered error (typedef enum) #17

Open
Tracked by #27
youyuanwu opened this issue Jun 28, 2022 · 0 comments
Open
Tracked by #27

c2v wrap sql.h encountered error (typedef enum) #17

youyuanwu opened this issue Jun 28, 2022 · 0 comments
Labels
Bug Something isn't working

Comments

@youyuanwu
Copy link

Hi, I am wrapping the odbc sql.h in linux using c2v but seems like the out file does not compile.

Repro steps: (I copied the sql.h from /usr/include to v repo)

bash:~/code/vlang/v/vlib/mssql$ ~/code/vlang/c2v/c2v wrap ./sql.h 
C to V translator 0.3.1
  translating ./sql.h         ... sql.v:101:15: error: unexpected token `(`, expecting name
   99 |     interval_type SQLINTERVAL
  100 |     interval_sign SQLSMALLINT
  101 |     intval Union (anonymous union at /usr/include/sqltypes.h
      |                  ^
  102 | }
  103 | type SQLBIGINT = int

Internal vfmt error while formatting file: ./sql.v.
Encountered a total of: 1 errors.
 took  1254 ms ; output .v file: ./sql.v
Translated   1 files in  1254 ms.

Problematic c code is this typedef enum in sqltypes.h

#if (ODBCVER >= 0x0300)
typedef enum
{
	SQL_IS_YEAR						= 1,
	SQL_IS_MONTH					= 2,
	SQL_IS_DAY						= 3,
	SQL_IS_HOUR						= 4,
	SQL_IS_MINUTE					= 5,
	SQL_IS_SECOND					= 6,
	SQL_IS_YEAR_TO_MONTH			= 7,
	SQL_IS_DAY_TO_HOUR				= 8,
	SQL_IS_DAY_TO_MINUTE			= 9,
	SQL_IS_DAY_TO_SECOND			= 10,
	SQL_IS_HOUR_TO_MINUTE			= 11,
	SQL_IS_HOUR_TO_SECOND			= 12,
	SQL_IS_MINUTE_TO_SECOND			= 13
} SQLINTERVAL;

#endif

Corresponding v code is :

struct SQL_INTERVAL_STRUCT { 
	interval_type SQLINTERVAL
	interval_sign SQLSMALLINT
	intval Union (anonymous union at /usr/include/sqltypes.h
}

c2v commit:

commit d7ac0c7b6830943c5441c94e17e62667a62e4934 (HEAD -> master, origin/master, origin/HEAD)
Author: Alexander Medvednikov <alexander@vlang.io>
Date:   Sun Jun 26 17:06:18 2022 +0300

    tests: remove unused files

v version:

V 0.2.4 28068e8
@ArtemkaKun ArtemkaKun added the Bug Something isn't working label Jul 4, 2022
@ArtemkaKun ArtemkaKun mentioned this issue Jul 4, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants